/* =====================================================================
   Marsault Property Management -- Espace proprietaire
   app.css -- Charte graphique MPM, alignee sur le site vitrine
   (marsaultproperty.fr / style2.css) : editorial, angles vifs,
   pas d'ombres, filet dore comme accent.
   ================================================================== */

:root {
  --brume:    #F2F5F8;
  --brume-d:  #D4DCE4;
  --blanc:    #FFFFFF;
  --nuit:     #1A3340;
  --mer:      #2C5264;
  --or:       #C9A84C;
  --or-l:     #E2C97A;
  --or-pale:  #F5EDD0;
  --muted:    #4A7C8C;

  /* Statuts / variations (memes valeurs que la vitrine) */
  --green:    #2d6e45;
  --green-bg: #e8f4ec;
  --amber:    #7a4f0a;
  --amber-bg: #fef3e2;
  --blue:     #0c447c;
  --blue-bg:  #e6f1fb;
  --red:      #a32d2d;

  --ink:      #1A3340;
  --ink-soft: #4A5A64;
  --line:     #D4DCE4;
  --card:     #FFFFFF;
  --ok:       #2d6e45;
  --warn:     #C9A84C;
  --danger:   #a32d2d;

  /* Angles vifs facon vitrine ; seuls quelques elements restent arrondis */
  --radius:   0px;
  --radius-s: 2px;
  --shadow:   0 1px 2px rgba(26,51,64,.05), 0 18px 40px rgba(26,51,64,.10);
  --shadow-s: none;

  --transition: .25s ease;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans:  "Jost", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---- Base ---------------------------------------------------------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--brume);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--nuit);
  line-height: 1.2;
  margin: 0 0 .4em;
  letter-spacing: .2px;
}
h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 300; }
h1 em { font-style: italic; color: var(--or); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a { color: var(--mer); text-decoration: none; }
a:hover { color: var(--nuit); }

p { margin: 0 0 1rem; }

img { max-width: 100%; }

/* Filet dore : accent recurrent de la vitrine */
.divider {
  width: 36px;
  height: 1.5px;
  background: var(--or);
  margin: 1rem 0 1.2rem;
}

/* ---- Topbar (sombre, identite du portail) ------------------------- */
.topbar {
  background: var(--nuit);
  color: #E8EEF2;
  position: sticky;
  top: 0;
  z-index: 60;
  border-bottom: 1px solid rgba(226,201,122,.18);
}
.topbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 61px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--sans);
  font-weight: 300;
  font-size: .95rem;
  letter-spacing: .22em;
  color: var(--or);
  white-space: nowrap;
  padding-right: 4px;
}
.brand:hover { color: var(--or-l); }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
  flex-wrap: wrap;
}
.nav a {
  color: #C6D2DA;
  padding: 8px 12px;
  font-size: .74rem;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  position: relative;
  white-space: nowrap;
  transition: color var(--transition);
}
.nav a:hover { color: #fff; }
.nav a.is-active { color: var(--or-l); }
.nav a.is-active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 0;
  height: 2px;
  background: var(--or);
}
.nav .badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin-left: 6px;
  font-size: .72rem;
  font-weight: 600;
  text-align: center;
  color: var(--nuit);
  background: var(--or-l);
  border-radius: 999px;
}

.topbar__aside {
  display: flex;
  align-items: center;
  gap: 14px;
}
.langswitch {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #7C93A0;
  font-size: .78rem;
}
.lang-btn {
  background: none;
  border: 0;
  color: #9DB0BB;
  font: inherit;
  font-size: .78rem;
  letter-spacing: .1em;
  cursor: pointer;
  padding: 2px 3px;
  transition: color var(--transition);
}
.lang-btn:hover { color: #fff; }
.lang-btn.is-active { color: var(--or-l); font-weight: 500; }

.user {
  font-size: .82rem;
  color: #B8C6CE;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Menu mobile (checkbox hack, pas de JS) */
.navtoggle { display: none; }
.navtoggle__btn { display: none; }

@media (max-width: 900px) {
  .topbar__inner { min-height: 57px; }
  .navtoggle__btn {
    display: block;
    order: 3;
    margin-left: auto;
    width: 30px; height: 24px;
    position: relative;
    cursor: pointer;
  }
  .navtoggle__btn span,
  .navtoggle__btn span::before,
  .navtoggle__btn span::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: var(--or-l);
  }
  .navtoggle__btn span { top: 11px; }
  .navtoggle__btn span::before { top: -7px; }
  .navtoggle__btn span::after  { top: 7px; }
  .nav {
    order: 5;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
  }
  .nav a { padding: 12px 4px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .nav a.is-active::after { display: none; }
  .navtoggle:checked ~ .nav { max-height: 460px; padding-bottom: 10px; }
  .topbar__aside { order: 4; }
}

/* ---- Bandeau "donnees de demonstration" -------------------------- */
.demo-banner {
  background: var(--or);
  border-bottom: 3px solid var(--mer);
  padding: .85rem 24px;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.demo-banner__icon { font-size: 1.15rem; flex-shrink: 0; color: var(--nuit); }
.demo-banner__body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.demo-banner__title {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--nuit);
}
.demo-banner__text {
  font-size: .78rem;
  font-weight: 300;
  line-height: 1.5;
  color: rgba(26, 51, 64, .82);
}
.demo-banner__badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .38rem .9rem;
  background: rgba(255, 255, 255, .35);
  color: var(--nuit);
  border: 1px solid rgba(26, 51, 64, .35);
  white-space: nowrap;
}
@media (max-width: 720px) {
  .demo-banner { padding: .8rem 16px; gap: .7rem; }
  .demo-banner__badge { display: none; }
}

/* ---- Layout ------------------------------------------------------- */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* En-tete de page facon vitrine : bandeau brume + tag dore + titre */
.page-head {
  margin: 0 -24px 26px;
  padding: 2.6rem 24px 2rem;
  background: var(--brume);
  border-bottom: 1px solid var(--brume-d);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.page-head::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 28%; height: 100%;
  background: var(--or);
  clip-path: polygon(22% 0%, 100% 0%, 100% 100%, 0% 100%);
  opacity: .07;
  pointer-events: none;
}
.page-head > * { position: relative; z-index: 1; }
.page-head__tag {
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--or);
  margin: 0 0 .45rem;
}
.page-head h1 { margin: 0; }
.page-head .sub {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 300;
  margin: .5rem 0 0;
}
.page-head .header-date { font-size: .78rem; font-weight: 300; }

/* Grilles fluides : autant de colonnes que la largeur le permet, sans
   points de rupture -- 2 (ou plus) elements par ligne des que possible. */
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ---- Cartes / panneaux ------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--brume-d);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card h2, .card h3 { margin-top: 0; }
.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
}
.card__head h2, .card__head h3 { margin: 0; }

.card-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--nuit);
  margin: 0 0 .15rem;
}
.card-sub {
  font-size: .73rem;
  font-weight: 300;
  color: var(--muted);
  margin: 0 0 1rem;
}

/* ---- Selecteur de bien : barre de pastilles (facon vitrine) ------ */
.bienbar {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  margin: 0 0 22px;
  padding: 0 0 2px;
}
.bienbar__label {
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.bienbar__btn {
  font-family: var(--sans);
  font-size: .76rem;
  font-weight: 400;
  letter-spacing: .05em;
  padding: .42rem 1rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--brume-d);
  border-radius: var(--radius-s);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.bienbar__btn:hover { border-color: var(--or); color: var(--or); }
.bienbar__btn.is-active {
  background: var(--nuit);
  color: #fff;
  border-color: var(--nuit);
}

/* ---- Metriques (cartes plates) ---------------------------------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--brume-d);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
}
.kpi .label {
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .55rem;
}
.kpi .value {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--nuit);
  line-height: 1;
  margin-bottom: .3rem;
}
.kpi .hint { font-size: .8rem; color: var(--ink-soft); margin-top: .2rem; }
.kpi__delta {
  margin: .35rem 0 0;
  font-size: .72rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

/* Variation N vs N-1 */
.delta { font-weight: 500; white-space: nowrap; font-size: .73rem; }
.delta--up   { color: var(--green); }
.delta--down { color: var(--red); }
.delta--flat { color: var(--muted); }

/* ---- Rangee de graphiques (asymetrique facon vitrine) ---------- */
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 22px;
}

.legend { display: flex; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .7rem; color: var(--muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

.chart-box { position: relative; height: 240px; }

/* ---- Rangee du bas : panneaux ---------------------------------- */
.bottom-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 22px;
  align-items: start;
}

/* ---- Positionnement concurrentiel ----------------------------- */
.pos-item { margin-bottom: .95rem; }
.pos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .3rem;
}
.pos-name { font-size: .76rem; color: var(--muted); font-weight: 300; }
.pos-name strong { font-weight: 500; color: var(--nuit); }
.pos-pct { font-size: .76rem; font-weight: 500; color: var(--nuit); }
.pos-track {
  background: var(--brume-d);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}
.pos-fill {
  height: 100%;
  border-radius: 3px;
  width: 0;
  transition: width .7s ease;
}
.pos-mine-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: .8rem;
  padding: .4rem .9rem;
  border: 1.5px solid var(--or);
  background: var(--or-pale);
  border-radius: var(--radius-s);
  font-size: .73rem;
  font-weight: 500;
  color: var(--mer);
}
.pos-comment {
  font-size: .73rem;
  font-weight: 300;
  color: var(--muted);
  line-height: 1.65;
  margin-top: .8rem;
  padding-top: .8rem;
  border-top: 1px solid var(--brume-d);
}
.pos-comment strong { font-weight: 600; }

/* ---- Boutons -------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: .76rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  line-height: 1;
  padding: .7rem 1.3rem;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none;
}
.btn--primary { background: var(--nuit); color: #fff; }
.btn--primary:hover { background: var(--mer); color: #fff; }
.btn--gold { background: var(--or); color: var(--nuit); }
.btn--gold:hover { background: var(--or-l); color: var(--nuit); }
.btn--ghost { background: transparent; border-color: var(--brume-d); color: var(--ink); }
.btn--ghost:hover { border-color: var(--muted); color: var(--nuit); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: .5rem .85rem; font-size: .68rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.topbar .btn--ghost { border-color: rgba(255,255,255,.22); color: #D6E0E6; }
.topbar .btn--ghost:hover { border-color: var(--or-l); color: #fff; }

/* ---- Formulaires ------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--nuit);
  margin-bottom: 6px;
}
.input, .select, textarea.input {
  width: 100%;
  font-family: var(--sans);
  font-size: .95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--brume-d);
  border-radius: var(--radius-s);
  padding: 11px 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--muted);
  box-shadow: 0 0 0 3px rgba(74,124,140,.15);
}
textarea.input { min-height: 110px; resize: vertical; }
.field .help { font-size: .78rem; color: var(--ink-soft); margin-top: 5px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 200px; }

/* ---- Alertes ---------------------------------------------- */
.alert {
  border-radius: var(--radius-s);
  padding: 12px 15px;
  font-size: .9rem;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert--error { background: #FBEDEB; border-color: #E7C5C0; color: #8F3529; }
.alert--ok    { background: var(--green-bg); border-color: #BFE0CD; color: #276048; }
.alert--info  { background: var(--blue-bg); border-color: #C4DCF1; color: var(--blue); }

/* ---- Tableaux ------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
table.data th {
  text-align: left;
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--brume-d);
  white-space: nowrap;
}
table.data td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--brume-d);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--brume); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot th {
  padding: 9px 10px;
  border-top: 1px solid var(--nuit);
  border-bottom: 0;
  font-size: .78rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--nuit);
  background: var(--brume);
}
/* Cellule "valeur + variation" empilee : garde les tableaux compacts */
.cell-v { display: block; }
.cell-delta { display: block; margin-top: 2px; font-size: .68rem; }

/* ---- Badges de statut --------------------------------- */
.status {
  display: inline-block;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status--confirmed { background: var(--blue-bg); color: var(--blue); border-color: #C4DCF1; }
.status--pending   { background: var(--amber-bg); color: var(--amber); border-color: #F0DCB8; }
.status--completed { background: var(--brume); color: var(--ink-soft); border-color: var(--brume-d); }
.status--cancelled { background: #F6E9E7; color: #9A4034; border-color: #E2C3BD; }
.status--on  { background: var(--green-bg); color: var(--green); border-color: #BFE0CD; }
.status--off { background: #F2EEED; color: #8A6B65; border-color: #DDD2CF; }

/* ---- Divers ------------------------------------------- */
.muted-text { color: var(--ink-soft); }
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--ink-soft);
  background: var(--brume);
  border: 1px solid var(--brume-d);
  border-radius: 999px;
  padding: 4px 11px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot--confirmed { background: var(--blue); }
.dot--pending   { background: var(--or); }
.dot--completed { background: var(--muted); }
.dot--cancelled { background: var(--brume-d); }

.section-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--nuit);
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--brume-d);
}

/* ---- Login ------------------------------------------- */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(44,82,100,.18), transparent 60%),
    var(--brume);
}
.auth__card {
  width: 100%;
  max-width: 410px;
  background: #fff;
  border: 1px solid var(--brume-d);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 34px 32px;
}
.auth__brand {
  text-align: center;
  font-family: var(--sans);
  font-weight: 300;
  letter-spacing: .4em;
  color: var(--or);
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.auth__title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 300;
  margin-bottom: 24px;
  color: var(--nuit);
}
.auth__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  font-size: .82rem;
}
.auth__foot .langswitch .lang-btn { color: var(--muted); }
.auth__foot .langswitch .lang-btn.is-active { color: var(--nuit); }
.auth__foot a { color: var(--muted); }

/* ---- Modale ----------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(16,32,40,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal__box {
  background: #fff;
  border-radius: var(--radius);
  max-width: 460px;
  width: 100%;
  padding: 26px 26px 22px;
  box-shadow: var(--shadow);
}
.modal__box h3 { margin-top: 0; }
.modal__row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--brume-d);
  font-size: .9rem;
}
.modal__row:last-of-type { border-bottom: 0; }
.modal__row span:first-child { color: var(--muted); }

/* ---- Messagerie ----------------------------------- */
.msg {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

/* Colonne : liste des conversations */
.msg__list { padding: 1rem 1.1rem; }
.msg__list-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: .8rem;
}
.msg__list-head h2 { font-size: 1.1rem; }

.thread-list { display: flex; flex-direction: column; gap: 4px; }
.thread-item {
  display: block;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: transparent;
  transition: background .15s, border-color .15s;
}
.thread-item:hover { background: var(--brume); }
.thread-item.is-active { border-color: var(--brume-d); background: var(--brume); }
.thread-item__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.thread-item__row + .thread-item__row { margin-top: 3px; }
.thread-item__subj {
  font-weight: 600;
  font-size: .88rem;
  color: var(--nuit);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-item__time { font-size: .66rem; color: var(--muted); flex-shrink: 0; }
.thread-item__snippet {
  flex: 1;
  min-width: 0;
  font-size: .78rem;
  font-weight: 300;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-item__snippet strong { font-weight: 500; color: var(--muted); }
.thread-item__badge {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--or);
  color: var(--nuit);
  font-size: .68rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Colonne : fil ouvert */
.msg__thread.card {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.msg__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--brume-d);
  background: var(--blanc);
}
.msg__head-txt { min-width: 0; }
.msg__subject {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--nuit);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg__peer {
  margin: 2px 0 0;
  font-size: .75rem;
  font-weight: 300;
  color: var(--muted);
}
.msg__dot { opacity: .5; }
.msg__back { display: none; }

.msg__scroll {
  padding: 1.25rem;
  overflow-y: auto;
  max-height: 56vh;
  display: flex;
  flex-direction: column;
  background: var(--brume);
  -webkit-overflow-scrolling: touch;
}
.msg__daysep { text-align: center; margin: 14px 0 10px; }
.msg__daysep:first-child { margin-top: 0; }
.msg__daysep span {
  display: inline-block;
  font-size: .66rem;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--blanc);
  border: 1px solid var(--brume-d);
  padding: 3px 12px;
  border-radius: 999px;
  text-transform: capitalize;
}

.msg-b {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: 13px;
  font-size: .9rem;
  line-height: 1.5;
  margin-top: 8px;
}
.msg-b--cont { margin-top: 2px; }
.msg-b--in {
  align-self: flex-start;
  background: var(--blanc);
  border: 1px solid var(--brume-d);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.msg-b--out {
  align-self: flex-end;
  background: var(--mer);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-b--in.msg-b--cont  { border-top-left-radius: 4px;  border-bottom-left-radius: 13px; }
.msg-b--out.msg-b--cont { border-top-right-radius: 4px; border-bottom-right-radius: 13px; }
.msg-b__who { font-size: .72rem; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.msg-b__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-b__time { font-size: .64rem; margin-top: 3px; opacity: .6; text-align: right; }
.msg-b--in .msg-b__time { color: var(--muted); opacity: .8; }

.msg__composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: .8rem 1rem;
  border-top: 1px solid var(--brume-d);
  background: var(--blanc);
}
.msg__input {
  flex: 1;
  min-width: 0;
  resize: none;
  font-family: var(--sans);
  font-size: .95rem;
  line-height: 1.4;
  color: var(--ink);
  background: var(--brume);
  border: 1px solid var(--brume-d);
  border-radius: 18px;
  padding: 10px 14px;
  max-height: 160px;
  transition: border-color .15s, background .15s;
}
.msg__input:focus { outline: none; border-color: var(--muted); background: #fff; }
.msg__send { flex-shrink: 0; border-radius: 18px; padding-left: 1.1rem; padding-right: 1.1rem; }

.msg__empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .7rem;
}
.msg__empty-icon { font-size: 2rem; opacity: .5; }

/* --- Mobile : un fil ouvert occupe tout l'ecran --- */
@media (max-width: 820px) {
  .msg { display: block; }
  .msg:not(.msg--open) .msg__thread { display: none; }
  .msg--open .msg__list { display: none; }
  .thread-item { padding: 13px 12px; }
  .thread-item__subj { font-size: .95rem; }
  .thread-item__snippet { font-size: .82rem; }

  /* Fil ouvert = plein ecran : on masque tout le chrome de la page */
  html.thread-open .topbar,
  html.thread-open .mpm-ib,
  html.thread-open .mpm-ib-help,
  html.thread-open .demo-banner,
  html.thread-open .page-head,
  html.thread-open .footer { display: none; }
  html.thread-open .wrap { padding: 0; margin: 0; max-width: none; }
  html.thread-open, html.thread-open body { overflow: hidden; height: 100%; }

  .msg--open .msg__thread.card {
    border: 0;
    height: 100vh;
    height: 100dvh;
  }
  .msg--open .msg__scroll { max-height: none; flex: 1 1 auto; }
  .msg__head {
    padding: .75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .msg__back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    font-size: .8rem;
    font-weight: 500;
    color: var(--mer);
  }
  .msg__back::before { content: "\2039"; font-size: 1.3em; line-height: 1; }
  .msg__subject { font-size: 1rem; }
  .msg__composer {
    padding: .65rem .75rem;
    padding-bottom: calc(.65rem + env(safe-area-inset-bottom));
  }
  .msg__input { font-size: 16px; } /* evite le zoom iOS au focus */
  .msg-b { max-width: 84%; }

  html.thread-open .alert {
    position: fixed;
    top: 8px; left: 8px; right: 8px;
    z-index: 20;
    margin: 0;
    box-shadow: 0 6px 20px rgba(26,51,64,.18);
  }
}

/* ---- Zone d'upload ------------------------------- */
.dropzone {
  border: 2px dashed var(--brume-d);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--brume);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.dropzone.is-over { border-color: var(--or); background: var(--or-pale); color: var(--nuit); }
.dropzone strong { color: var(--nuit); }
.dropzone input[type=file] { display: none; }

/* ---- Footer ------------------------------------- */
.footer {
  border-top: 1px solid var(--brume-d);
  background: var(--brume);
}
.footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: .8rem;
  color: var(--ink-soft);
}

/* ---- Utilitaires ------------------------------- */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.hide { display: none; }
.help { font-size: .73rem; font-weight: 300; color: var(--muted); line-height: 1.6; margin: .8rem 0 0; }

/* ---- Menage : check-list de l'agent ------------ */
.select--sm { padding: .4rem .55rem; font-size: .8rem; max-width: 200px; }
tr.row-warn > td { background: var(--amber-bg); }

.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item { margin: 0; }
.check-item__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: var(--brume);
  border: 1px solid var(--brume-d);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  text-align: left;
  cursor: pointer;
}
.check-item__btn:hover { border-color: var(--muted); }
.check-item__box {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  color: var(--nuit);
  background: #fff;
}
.check-item.is-done .check-item__btn {
  background: var(--green-bg);
  border-color: #BFE0CD;
  color: var(--green);
}
.check-item.is-done .check-item__box {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.check-item.is-done .check-item__label { text-decoration: line-through; opacity: .75; }

@media (max-width: 640px) {
  .check-item__btn { padding: 16px 14px; font-size: 1rem; }
}

.chip--sm { font-size: .62rem; padding: .1rem .4rem; vertical-align: middle; }

/* ---- Menage : fenetre + creneaux proposes ------ */
.window-box {
  border: 1px solid var(--brume-d);
  background: var(--brume);
  padding: 10px 12px;
  font-size: .9rem;
  line-height: 1.5;
  margin: 0 0 12px;
}
.slot-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }

/* ---- Menage : photos avant / apres ------------- */
.photo-phase { margin-top: 14px; }
.photo-phase__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.photo-add { margin: 0; }
.photo-add label { cursor: pointer; margin: 0; }
.photo-add input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-thumb { position: relative; margin: 0; border: 1px solid var(--brume-d); background: var(--brume); }
.photo-thumb img { display: block; width: 100%; height: 96px; object-fit: cover; }
.photo-thumb__badge {
  position: absolute; left: 0; bottom: 0; right: 0;
  background: rgba(26,51,64,.82); color: #fff; font-size: .58rem;
  padding: 2px 4px; text-align: center; letter-spacing: .02em;
}
.photo-thumb__del { position: absolute; top: 0; right: 0; margin: 0; }
.photo-thumb__del button {
  border: 0; background: rgba(26,51,64,.72); color: #fff;
  width: 22px; height: 22px; line-height: 20px; font-size: 15px; cursor: pointer; padding: 0;
}
.photo-thumb__del button:hover { background: var(--nuit); }
.photo-grid--admin { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.photo-grid--admin .photo-thumb img { height: 120px; }
.photo-thumb__share { margin: 0; }
.photo-thumb__share button {
  width: 100%; border: 0; border-top: 1px solid var(--brume-d);
  background: var(--brume); color: var(--ink-soft);
  font-size: .64rem; padding: 4px 4px; cursor: pointer;
}
.photo-thumb__share button.is-on { background: var(--green); color: #fff; }
.photo-thumb__share button:hover { filter: brightness(.97); }
@media (max-width: 640px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
  .photo-thumb img { height: 84px; }
  .photo-grid--admin { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ---- Menage : calendrier admin ----------------- */
.cal-bar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.cal-bar__nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-bar__title { font-family: var(--serif, inherit); font-size: 1.15rem; color: var(--nuit); }

.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .72rem; color: var(--ink-soft); margin: 4px 0 14px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-dot { width: 10px; height: 10px; display: inline-block; border: 1px solid var(--brume-d); }

.cal-ev--todo     { background: var(--amber-bg); border-color: #F0DCB8; color: var(--amber); }
.cal-ev--planned  { background: var(--blue-bg);  border-color: #C4DCF1; color: var(--blue); }
.cal-ev--progress { background: #FBE7C6; border-color: #E7C58A; color: #7a4f0a; }
.cal-ev--done     { background: var(--green-bg); border-color: #BFE0CD; color: var(--green); }
.cal-ev--off      { background: #F2EEED; border-color: #DDD2CF; color: #8A6B65; }

.cal { border: 1px solid var(--brume-d); border-left: 0; border-top: 0; }
.cal--month { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-hd {
  border-top: 1px solid var(--brume-d); border-left: 1px solid var(--brume-d);
  background: var(--brume); font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft); padding: 6px 8px; text-align: center;
}
.cal-cell {
  border-top: 1px solid var(--brume-d); border-left: 1px solid var(--brume-d);
  min-height: 96px; padding: 4px; display: flex; flex-direction: column; gap: 3px;
}
.cal-cell.is-out { background: #FAFBFC; }
.cal-cell.is-out .cal-cell__n { color: var(--brume-d); }
.cal-cell.is-today { background: var(--or-pale); }
.cal-cell__n { font-size: .75rem; font-weight: 600; color: var(--ink-soft); }

.cal-ev {
  display: flex; align-items: baseline; gap: 4px; text-decoration: none;
  border: 1px solid var(--brume-d); padding: 2px 5px; font-size: .68rem; line-height: 1.3;
  white-space: nowrap; overflow: hidden;
}
.cal-ev:hover { filter: brightness(.97); }
.cal-ev__t { font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-ev__k { font-weight: 700; }
.cal-ev__p { overflow: hidden; text-overflow: ellipsis; }
.cal-ev__a { margin-left: auto; opacity: .8; }
.cal-more { font-size: .66rem; color: var(--muted); text-decoration: none; padding: 0 5px; }
.cal-more:hover { color: var(--or); }

.cal--week { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-col { border-top: 1px solid var(--brume-d); border-left: 1px solid var(--brume-d); display: flex; flex-direction: column; }
.cal-col.is-today { background: var(--or-pale); }
.cal-col__head { padding: 6px 8px; font-size: .72rem; color: var(--ink-soft); border-bottom: 1px solid var(--brume-d); background: var(--brume); }
.cal-col__head strong { font-size: .95rem; color: var(--nuit); margin-left: 4px; }
.cal-col__body { padding: 5px; display: flex; flex-direction: column; gap: 4px; min-height: 90px; }
.cal-col__body .cal-ev { white-space: normal; flex-wrap: wrap; }
.cal-col__empty { color: var(--brume-d); font-size: .8rem; text-align: center; padding: 8px 0; }

@media (max-width: 820px) {
  .cal--month { font-size: .9em; }
  .cal-cell { min-height: 74px; }
  .cal-ev__p { display: none; }
  .cal--week { grid-template-columns: 1fr; }
}

@media print { .topbar, .footer, .btn { display: none; } .page-head::before { display: none; } }
