/* ==========================================================================
   Maquette de gestion locative — feuille de style unique.
   Mobile-first : les regles de base valent pour telephone, les @media
   elargissent ensuite (>=720px tablette, >=1080px bureau).
   ========================================================================== */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;

  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --teal: #0d9488;
  --teal-soft: #ccfbf1;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --green: #15803d;
  --green-soft: #dcfce7;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);

  --sidebar-w: 236px;
  --header-h: 56px;
  --day-w: 46px;      /* largeur d'une colonne jour du calendrier (mobile) */
  --label-w: 116px;   /* colonne collante des noms de logement */
  --row-h: 40px;
}

* { box-sizing: border-box; }

/* Pas de « height: 100% » sur html/body : sur mobile, la hauteur de l'écran
   change quand la barre d'adresse se replie, et la barre d'onglets fixée en
   bas se retrouvait au milieu de la page pendant le défilement. */
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Ossature ---------------------------------------------------- */

.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.brand-text { font-size: 15px; }

.topbar-spacer { flex: 1; }

.icon-btn {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.role-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 12px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent);
}

.body-wrap { flex: 1; display: flex; min-height: 0; }

/* ---------- Navigation -------------------------------------------------- */

.sidebar {
  position: fixed; inset: var(--header-h) auto 0 0; z-index: 45;
  width: var(--sidebar-w); padding: 12px 10px;
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .22s ease;
  overflow-y: auto;
}
.sidebar.open { transform: none; }

.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); padding: 12px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { flex: 0 0 auto; }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 650;
  background: var(--red-soft); color: var(--red);
  padding: 1px 7px; border-radius: 999px;
}
.nav-item.locked { opacity: .42; cursor: not-allowed; }
.nav-item.locked:hover { background: none; color: var(--muted); }

.scrim {
  position: fixed; inset: 0; z-index: 44; background: rgba(15, 23, 42, .38);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.main { flex: 1; min-width: 0; padding: 14px 12px 84px; }

/* Barre d'onglets basse — mobile uniquement. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  /* Calque propre : reste collée en bas même pendant le défilement inertiel. */
  transform: translateZ(0);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 7px; font-size: 10.5px; color: var(--muted); position: relative;
}
.tabbar a.active { color: var(--accent); font-weight: 600; }
.tabbar .dot {
  position: absolute; top: 6px; right: 50%; margin-right: -14px;
  width: 7px; height: 7px; border-radius: 50%; background: #ef4444;
}

/* ---------- Titres et blocs -------------------------------------------- */

.page-head { margin-bottom: 14px; }
.page-title { font-size: 20px; font-weight: 660; margin: 0 0 3px; letter-spacing: -.015em; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-title { font-size: 14px; font-weight: 620; margin: 0; }
.card-body { padding: 14px; }
/* Un enfant de grille vaut `min-width:auto` par defaut : sans ce 0, une rangee
   de chips large impose sa taille intrinseque a la carte, qui deborde alors la
   page entiere en scroll horizontal. */
.card-body > * { min-width: 0; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 12px; }

/* ---------- Statistiques ------------------------------------------------ */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 13px; box-shadow: var(--shadow);
}
.stat-label { font-size: 11.5px; color: var(--muted); font-weight: 550; }
.stat-value { font-size: 24px; font-weight: 680; letter-spacing: -.02em; margin-top: 3px; }
.stat-hint { font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.stat.alert .stat-value { color: var(--red); }

/* ---------- Contrôles --------------------------------------------------- */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* `1 1 150px` : deux filtres tiennent cote a cote sur telephone au lieu de
   prendre chacun toute la largeur. */
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 150px; }
.field select, .field input { width: 100%; }
/* Le champ qui ne porte qu'un bouton ne doit pas s'etirer comme un filtre. */
.field.action { flex: 0 0 auto; }
.field label { font-size: 11px; color: var(--muted); font-weight: 550; }
.input, select.input {
  padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); min-width: 0;
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; font-weight: 550; color: var(--muted); white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .swatch { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 auto; }

/* Mobile : bande defilante. Tablette et plus : les chips passent a la ligne. */
.chip-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.chip-row::-webkit-scrollbar { height: 0; }

/* ---------- Badges ------------------------------------------------------ */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge.accepted { background: var(--green-soft); color: var(--green); }
.badge.cancelled, .badge.not-accepted { background: var(--red-soft); color: var(--red); }
.badge.checkpoint { background: var(--amber-soft); color: var(--amber); }
.badge.airbnb { background: #ffe4e6; color: #be123c; }
.badge.booking { background: #dbeafe; color: #1d4ed8; }
.badge.direct { background: var(--accent-soft); color: var(--accent); }

/* Marqueur de champ rempli par l'IA. */
.ai-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 650; letter-spacing: .02em;
  padding: 1px 6px; border-radius: 5px;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff); color: #6d28d9;
}
.ai-tag.low { background: var(--amber-soft); color: var(--amber); }

/* ---------- Tableaux ---------------------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--faint); font-weight: 600; white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.nowrap { white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }

/* Sur mobile, chaque ligne devient une carte empilee. */
.stack-cards { display: grid; gap: 9px; }
.res-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 12px; box-shadow: var(--shadow);
}
.res-card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.res-card-name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-card-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; font-size: 12.5px; color: var(--muted); }
.res-card-meta b { color: var(--text); font-weight: 600; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent);
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

.prop-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; display: inline-block; }

/* ==========================================================================
   Calendrier multi-logements
   ========================================================================== */

.cal-shell { border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }

.cal-scroll { overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; }

.cal-grid { min-width: max-content; }

.cal-row { display: grid; grid-auto-flow: dense; align-items: stretch; }
/* La 1re colonne (nom du logement) est collante a gauche pendant le scroll. */
.cal-label {
  position: sticky; left: 0; z-index: 3;
  grid-column: 1; grid-row: 1 / -1;
  padding: 8px 10px;
  background: var(--surface); border-right: 1px solid var(--border-strong);
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
}
.cal-label-name { font-size: 12.5px; font-weight: 620; line-height: 1.25; }
.cal-label-sub { font-size: 11px; color: var(--faint); }

.cal-head { border-bottom: 1px solid var(--border-strong); background: var(--surface-2); }
.cal-head .cal-label { background: var(--surface-2); }
.cal-day {
  width: var(--day-w); padding: 5px 0 6px; text-align: center;
  border-left: 1px solid var(--border);
  font-size: 11px; color: var(--muted); line-height: 1.25;
}
.cal-day .dnum { display: block; font-size: 13px; font-weight: 620; color: var(--text); }
.cal-day.we { background: #f1f5f9; }
.cal-day.today { background: var(--accent-soft); }
.cal-day.today .dnum { color: var(--accent); }
.cal-month {
  font-size: 11px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 0 3px 6px; border-left: 1px solid var(--border);
}

.cal-body-row { border-bottom: 1px solid var(--border); position: relative; }
.cal-cell { width: var(--day-w); border-left: 1px solid var(--border); grid-row: 1 / -1; }
.cal-cell.we { background: #f8fafc; }
.cal-cell.today { background: rgba(79, 70, 229, .06); }

.cal-lane { grid-row: auto; height: var(--row-h); position: relative; }

/* Barre de sejour */
.stay {
  grid-row: var(--lane);
  margin: 3px 2px; padding: 0 7px;
  border-radius: 6px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  background: var(--teal); color: #fff;
  font-size: 11.5px; line-height: 1.2; min-width: 0; z-index: 2;
  cursor: pointer; border: 1px solid rgba(0, 0, 0, .06);
}
.stay:hover { filter: brightness(1.06); box-shadow: var(--shadow-lg); }
.stay.cancelled {
  background: repeating-linear-gradient(45deg, #fca5a5, #fca5a5 6px, #fecaca 6px, #fecaca 12px);
  color: #7f1d1d; text-decoration: line-through;
}
.stay.checkpoint { background: #d97706; }
.stay-line { display: flex; align-items: center; gap: 5px; min-width: 0; }
.stay-name {
  font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stay-meta {
  display: flex; gap: 7px; font-size: 10.5px; opacity: .93;
  overflow: hidden; white-space: nowrap;
}
.stay-meta span { display: inline-flex; align-items: center; gap: 3px; }

/* --- Calques : masques par defaut, reveles par une classe sur <body> ----- */
.lyr { display: none !important; }
body.l-guest   .lyr-guest   { display: flex !important; }
body.l-guests  .lyr-guests  { display: inline-flex !important; }
body.l-in      .lyr-in      { display: inline-flex !important; }
body.l-out     .lyr-out     { display: inline-flex !important; }
body.l-channel .lyr-channel { display: inline-flex !important; }
body.l-price   .lyr-price   { display: inline-flex !important; }
body.l-clean   .lyr-clean   { display: inline-flex !important; }
body.l-request .lyr-request { display: inline-flex !important; }
/* La 2e ligne de la barre n'apparait que si au moins un calque « meta » est actif. */
body.l-guests .stay-meta, body.l-in .stay-meta, body.l-out .stay-meta,
body.l-channel .stay-meta, body.l-price .stay-meta, body.l-clean .stay-meta,
body.l-request .stay-meta { display: flex !important; }
.stay-meta { display: none !important; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block;
  vertical-align: -2px; margin-right: 5px; }

/* ==========================================================================
   Messagerie
   ========================================================================== */

.mail { display: grid; gap: 12px; }

.thread-list { display: grid; gap: 0; }
.thread-item {
  display: flex; gap: 10px; padding: 11px 12px;
  border-bottom: 1px solid var(--border); cursor: pointer; background: var(--surface);
}
.thread-item:hover { background: var(--surface-2); }
.thread-item.active { background: var(--accent-soft); }
.thread-item.unread .thread-name { font-weight: 700; }
.thread-item.unread .thread-preview { color: var(--text); }
.thread-main { flex: 1; min-width: 0; }
.thread-top { display: flex; align-items: baseline; gap: 8px; }
.thread-name { font-size: 13.5px; font-weight: 550; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-time { font-size: 11px; color: var(--faint); flex: 0 0 auto; }
.thread-sub { font-size: 11.5px; color: var(--faint); margin: 1px 0 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-preview {
  font-size: 12.5px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.thread-flags { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }

.pending-flag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--red-soft); color: var(--red);
  font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px;
}
.pending-flag.ok { background: var(--green-soft); color: var(--green); }

/* Conversation */
.conv-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.conv-body { padding: 14px; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface-2); }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; }
.bubble .when { display: block; font-size: 10.5px; opacity: .7; margin-top: 4px; }
.bubble.guest { background: var(--surface); border: 1px solid var(--border); align-self: flex-start;
  border-bottom-left-radius: 3px; }
.bubble.host { background: var(--accent); color: #fff; align-self: flex-end;
  border-bottom-right-radius: 3px; }

.suggest {
  margin: 12px 14px 0; padding: 12px;
  border: 1px dashed #c7d2fe; border-radius: var(--radius);
  background: linear-gradient(180deg, #f5f3ff, #eef2ff);
}
.suggest-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.suggest-title { font-size: 12.5px; font-weight: 650; color: #4338ca; }
.suggest-text { font-size: 13.5px; color: #312e81; margin: 0 0 10px; }
.suggest-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.composer { padding: 12px 14px; border-top: 1px solid var(--border); }
.composer textarea {
  width: 100%; min-height: 76px; resize: vertical;
  padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.composer-actions { display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Sur mobile la messagerie fonctionne en deux ecrans (liste -> conversation). */
.mail-pane-list, .mail-pane-conv { min-width: 0; }
body.conv-open .mail-pane-list { display: none; }
body:not(.conv-open) .mail-pane-conv { display: none; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  color: var(--accent); font-weight: 550; margin-bottom: 10px; }

/* ==========================================================================
   Fiche reservation
   ========================================================================== */

.detail-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.detail-title { font-size: 18px; font-weight: 660; margin: 0; letter-spacing: -.015em; }
.detail-sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

.kv { display: grid; grid-template-columns: 1fr; gap: 0; }
.kv-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed var(--border);
}
.kv-row:last-child { border-bottom: 0; }
.kv-key { font-size: 12.5px; color: var(--muted); flex: 0 0 auto; }
.kv-val { font-size: 13.5px; font-weight: 550; text-align: right;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 13px; font-size: 13.5px; font-weight: 550; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; padding-top: 14px; }
.tab-panel.active { display: block; }

/* Mini frise du sejour dans son mois */
.strip { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.strip-days { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.strip-day {
  flex: 0 0 34px; text-align: center; padding: 6px 0 7px;
  border-left: 1px solid var(--border); font-size: 11px; color: var(--muted);
}
.strip-day:first-child { border-left: 0; }
.strip-day .n { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); }
.strip-day.in-stay { background: var(--teal-soft); }
.strip-day.edge-start { border-radius: 6px 0 0 6px; background: var(--teal); color: #fff; }
.strip-day.edge-end { border-radius: 0 6px 6px 0; background: var(--teal); color: #fff; }
.strip-day.edge-start .n, .strip-day.edge-end .n { color: #fff; }
.strip-day.other { background: #fafafa; color: var(--faint); }
.strip-day.busy { background: #fee2e2; }

.note {
  border-left: 3px solid var(--accent); background: var(--surface-2);
  padding: 9px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.note + .note { margin-top: 9px; }
.note-head { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.note-text { font-size: 13.5px; }

/* ---------- Divers ------------------------------------------------------ */

.empty { text-align: center; color: var(--faint); padding: 30px 16px; font-size: 13.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hr { height: 1px; background: var(--border); border: 0; margin: 14px 0; }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--radius); font-size: 13px;
  background: var(--amber-soft); color: #78350f; border: 1px solid #fde68a;
  margin-bottom: 12px;
}
.banner.info { background: var(--accent-soft); color: #3730a3; border-color: #c7d2fe; }
.banner strong { display: block; margin-bottom: 2px; }

.banner.flash-ok { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.banner.flash-error { background: var(--red-soft); color: var(--red); border-color: #fca5a5; }
.banner.flash-secret { background: var(--accent-soft); color: #3730a3; border-color: #c7d2fe;
  font-weight: 600; word-break: break-all; }

/* Utilisateur connecte (en-tete). */
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.user-name { display: block; font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role { display: block; font-size: 11.5px; color: var(--muted); }

/* Pages de connexion / compte. */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: var(--bg, #f8fafc); }
.auth-card { width: 100%; max-width: 380px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack .field { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.perm-yes { color: var(--green); font-weight: 700; }
.perm-no { color: var(--faint); }

/* ==========================================================================
   Tablette
   ========================================================================== */

@media (min-width: 720px) {
  :root { --day-w: 58px; --row-h: 44px; --label-w: 150px; }
  .main { padding: 20px 22px 40px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .page-title { font-size: 23px; }
  .mail { grid-template-columns: 320px 1fr; align-items: start; }
  body.conv-open .mail-pane-list { display: block; }
  body:not(.conv-open) .mail-pane-conv { display: block; }
  .back-link { display: none; }
  .detail-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; align-items: start; }
  .chip-row { flex-wrap: wrap; overflow-x: visible; }
}

/* ==========================================================================
   Bureau : la barre laterale devient permanente, la tabbar disparait
   ========================================================================== */

@media (min-width: 1080px) {
  :root { --day-w: 62px; --label-w: 168px; }
  .sidebar { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h));
    transform: none; border-right: 1px solid var(--border); }
  .body-wrap { align-items: flex-start; }
  .scrim { display: none; }
  .tabbar { display: none; }
  .main { padding: 22px 26px 40px; }
  .menu-btn { display: none; }
  .mail { grid-template-columns: 360px 1fr; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 719px) {
  .desktop-only { display: none !important; }
  /* Le lien retour passe sur sa propre ligne : sinon le nom du voyageur et le
     logement se retrouvent comprimes sur 20 px de large. */
  .conv-head .back-link { flex: 0 0 100%; margin: 0 0 2px; }
  .field { flex: 1 1 130px; }
}
@media (min-width: 720px) {
  .mobile-only { display: none !important; }
}

/* ==========================================================================
   Calendrier réel (étape 2) — spec § 2. Grille SVG, colonne des logements
   fixe, défilement horizontal dans sa carte seulement.
   ========================================================================== */
.cal-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; flex: 1 1 220px; max-width: 340px; }
.seg button { font: inherit; font-size: 13px; flex: 1; border: 0; background: none; color: var(--muted); padding: 7px; border-radius: 6px; cursor: pointer; min-height: 34px; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.box { font: inherit; font-size: 12.5px; padding: 6px 11px; min-height: 32px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.box::before { content: ""; width: 9px; height: 9px; border-radius: 2px; border: 1.5px solid currentColor; }
.chip.box[aria-pressed="true"] { color: var(--text); border-color: var(--text); }
.chip.box[aria-pressed="true"]::before { background: currentColor; }
.cal-week { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cal-range { flex: 1; text-align: center; font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 6px 6px; min-width: 0; }
.cal-grid { display: flex; min-width: 0; }
#calLab { flex: none; display: block; }
.cal-scroll { flex: 1; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
#cal { display: block; }
#cal text, #calLab text { font-family: inherit; }
.c-mut { fill: var(--muted); } .c-faint { fill: var(--faint); } .c-ink { fill: var(--text); }
.c-bad { fill: var(--red); } .c-ok { fill: var(--green); } .c-warn { fill: var(--amber); } .c-acc { fill: var(--accent); }
.c-num { font-variant-numeric: tabular-nums; }
.c-row { fill: var(--surface-2); } .c-grid { stroke: var(--border); }
.c-iv { fill: var(--surface); stroke: var(--border); }
.c-cancel { stroke: var(--red); fill: none; }
.c-bar { cursor: pointer; }
.c-bar:focus { outline: none; }
.c-bar:focus-visible .c-shape { stroke: var(--accent); stroke-width: 2.5; }
.cal-slider { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.cal-slider input { flex: 1; max-width: 320px; accent-color: var(--accent); }

.sheet { position: fixed; inset: 0; background: rgba(10, 12, 15, .5); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-in { background: var(--bg); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; border-radius: 14px 14px 0 0; padding: 14px 16px calc(22px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 900px) {
  .sheet { justify-content: flex-end; align-items: stretch; background: rgba(10, 12, 15, .28); }
  .sheet-in { max-width: 420px; max-height: none; height: 100%; border-radius: 0; border-left: 1px solid var(--border); }
}
.sh-head { display: flex; align-items: center; gap: 10px; }
.sh-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sh-title { font-size: 15px; font-weight: 600; margin: 0; }
.sh-sub { font-size: 12px; color: var(--muted); margin: 0; }
.sh-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.sh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sh-stat { background: var(--bg); border-radius: 8px; padding: 9px 10px; min-width: 0; }
.sh-stat .k { font-size: 11.5px; color: var(--muted); margin: 0; }
.sh-stat .n { font-size: 18px; font-weight: 600; margin: 2px 0 0; }
.sh-stat .s { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }
.sh-kv { width: 100%; font-size: 13px; border-collapse: collapse; margin-top: 8px; }
.sh-kv td { padding: 5px 0; vertical-align: top; }
.sh-kv td:first-child { color: var(--muted); padding-right: 10px; }
.sh-kv td:last-child { text-align: right; }
.sh-h3 { font-size: 13.5px; font-weight: 600; margin: 4px 0 0; }

/* ==========================================================================
   Ménage réel (étape 3) — spec § 6.
   ========================================================================== */
.mn-section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.mn-h2 { font-size: 14px; font-weight: 650; margin: 4px 0 0; color: var(--muted); letter-spacing: .02em; }
.mn-card { border-left: 4px solid var(--border); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.mn-past { opacity: .72; }
.mn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mn-title { font-size: 14.5px; font-weight: 650; margin: 0; flex: 1; min-width: 0; }
.mn-line { font-size: 13.5px; margin: 0; line-height: 1.5; }
.mn-help { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.mn-tag { font-size: 11.5px; padding: 2px 8px; border-radius: 5px; white-space: nowrap; }
.mn-tag.ok { background: var(--green-soft); color: var(--green); }
.mn-tag.warn { background: var(--amber-soft); color: var(--amber); }
.mn-tag.bad { background: var(--red-soft); color: var(--red); }
.mn-tag.mut { background: var(--surface-2); color: var(--muted); }
.mn-ok { color: var(--green); } .mn-warn { color: var(--amber); } .mn-bad { color: var(--red); }
.mn-form { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.mn-form textarea { width: 100%; resize: vertical; }
.mn-label { font-size: 12px; color: var(--muted); font-weight: 550; }
.mn-grid2 { display: grid; grid-template-columns: 1fr; gap: 8px; }
.mn-grid2 > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@media (min-width: 560px) { .mn-grid2 { grid-template-columns: 1fr 1fr; } }
.mn-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.mn-more { border-top: 1px solid var(--border); padding-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.mn-more[open] { display: flex; }
.mn-more summary { cursor: pointer; color: var(--accent); font-size: 13px; padding: 4px 0; }
.mn-more input[type=file] { font-size: 13px; }
.mn-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.mn-photos img { width: 72px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.mn-issue { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 6px; }
.mn-issue .mn-line { flex: 1; min-width: 0; }
.mn-team { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.mn-team li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mn-switch label { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 12px; }
.mn-alert { border-left-color: var(--amber); }
.mn-ask summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Aperçu du calendrier intégré à l'onglet Ménage (iframe). */
body.cal-embed { background: transparent; padding: 2px; }
body.cal-embed .cal-week { margin-bottom: 6px; flex-wrap: wrap; }
.seg-sm { flex: 0 1 220px; }
.seg-sm button { font-size: 12px; min-height: 30px; padding: 4px; }
.c-focus { fill: var(--accent-soft); }
.c-focus-row { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.mn-preview { width: 100%; border: 0; display: block; min-height: 120px; background: transparent; }

/* Calendrier : période, panneau « Affichage » à interrupteurs, marges réduites. */
.seg-period { flex: 0 1 200px; }
.disp { position: relative; }
/* Téléphone : panneau calé dans l'écran (jamais de défilement horizontal). */
.disp-panel { position: fixed; z-index: 50; left: 12px; right: 12px; top: 140px; max-height: calc(100vh - 220px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 12px; }
@media (min-width: 560px) { .disp-panel { position: absolute; top: calc(100% + 6px); left: auto; right: 0; width: 310px; max-height: none; } }
.disp-title { font-size: 12px; font-weight: 650; color: var(--muted); margin: 0 0 4px; }
.sw-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.sw-line:last-child { border-bottom: 0; }
/* Interrupteur façon iPhone : gris éteint, vert allumé. */
.sw { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; background: #d1d5db; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.sw:checked { background: #34c759; }
.sw:checked::after { transform: translateX(18px); }
.sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.c-same { fill: var(--green); }
body.page-cal .main { padding-left: 6px; padding-right: 6px; }
body.page-cal .page-head, body.page-cal .cal-tools, body.page-cal .cal-week, body.page-cal .cal-slider, body.page-cal .main > p { padding-left: 6px; padding-right: 6px; }
.cal-card { padding: 6px 2px 4px; }
@media (min-width: 1080px) { body.page-cal .main { padding-left: 18px; padding-right: 18px; } }
