:root {
  color-scheme: light;
  --ink: #14231e;
  --muted: #6d7d76;
  --line: #dde6e1;
  --paper: #ffffff;
  --canvas: #f4f7f5;
  --green: #175c43;
  --green-2: #1e7655;
  --green-soft: #e7f3ed;
  --gold: #c69342;
  --red: #b64b48;
  --shadow: 0 18px 48px rgba(24, 63, 47, .12);
  --shadow-sm: 0 2px 8px rgba(20, 35, 30, .06);
  --shadow-md: 0 8px 22px rgba(20, 35, 30, .09);
  --ring: 0 0 0 3px rgba(30, 118, 85, .20);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  overflow: hidden;
}

button, input, textarea, select { font: inherit; }

button { cursor: pointer; }

.hidden { display: none !important; }

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  color: #fff;
  background: linear-gradient(120deg, #123d31, #175c43);
}

.brand, .connection, .chat-header, .panel-heading, .queue-heading,
.dialog-heading, .dialog-actions, .recipient-card { display: flex; align-items: center; }

.brand { gap: 12px; }

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 12px;
  font-family: Georgia, serif;
  letter-spacing: -.04em;
}

.brand strong, .brand span { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 20px; }
.brand span { opacity: .68; font-size: 12px; }

.connection { gap: 10px; }

.phone-priority {
  padding: 6px 9px;
  color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.phone-priority.active {
  color: #d8ffeb;
  background: rgba(54,166,111,.18);
  border-color: rgba(114,216,167,.38);
}
.phone-priority.warning {
  color: #ffe4c2;
  background: rgba(182,75,72,.2);
  border-color: rgba(255,190,170,.35);
}

.connection select {
  min-width: 190px;
  color: #fff;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 9px;
  padding: 9px 12px;
}

.connection select option { color: var(--ink); }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d3a653;
  box-shadow: 0 0 0 4px rgba(211,166,83,.16);
}

.dot.connected { background: #72d8a7; box-shadow: 0 0 0 4px rgba(114,216,167,.15); }

.button {
  /* `inline-flex` explicite : sans display déclaré, un `<a class="button">`
     restait une boîte en ligne, sur laquelle `width: 100%`, `min-height` et
     `justify-content` étaient tous ignorés. Dans le tiroir mobile, le lien
     « Connexion QR » se réduisait à une pastille de 20 px chevauchant ses
     voisins, au milieu d'une colonne de boutons pleine largeur. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { color: #fff; background: var(--green); }
.button.secondary { color: var(--green); background: var(--green-soft); }
.button.ghost { color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); }
.button.full { width: 100%; }

.app-shell {
  height: calc(100vh - 74px);
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 1px;
  background: var(--line);
}

.contacts-panel, .chat-panel, .automation-panel {
  min-width: 0;
  background: var(--paper);
}

.contacts-panel, .automation-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-heading, .queue-heading { justify-content: space-between; }
.panel-heading { padding: 24px 20px 14px; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin-bottom: 0; font-size: 27px; }
h2 { margin-bottom: 0; font-size: 23px; }

.count {
  min-width: 34px;
  padding: 5px 9px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 12px;
  padding: 0 12px;
  background: var(--canvas);
  border: 1px solid transparent;
  border-radius: 10px;
}

.search:focus-within { border-color: #82af9d; background: #fff; }

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 11px 0;
  background: transparent;
}

.contact-filters {
  display: grid;
  gap: 7px;
  margin: 0 16px 12px;
}

.contact-filters select {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  font-size: 11px;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.source-tab {
  padding: 13px 4px 11px;
  color: var(--muted);
  background: #fff;
  border: 0;
  border-bottom: 3px solid transparent;
  font-size: 11px;
  font-weight: 800;
}

.source-tab.active { color: var(--green); border-color: var(--green); }
.source-tab:hover { color: var(--green); }

.contact-copy .contact-preview {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.contact-copy strong .unread-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 1px 6px;
  color: #fff;
  background: var(--green-2);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  font-style: normal;
  text-align: center;
  vertical-align: middle;
}

.contact-copy .contact-phone .chat-time {
  float: right;
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
}

.contact-filters select:focus {
  border-color: #82af9d;
  box-shadow: 0 0 0 3px rgba(23,92,67,.07);
}

.source-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 18px 12px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
}

.source-status span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #aab5b0;
}

.source-status.connected .source-dot { background: #36a66f; }
.source-status.warning .source-dot { background: var(--red); }

.contact-list, .template-list, .schedule-list {
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.contact-list { flex: 1; }

.contact-row {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 13px 18px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid #edf1ef;
}

.contact-row:hover { background: #f8faf9; }
.contact-row.active { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }

.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(140deg, #4f8a72, #194d3b);
  font-family: Georgia, serif;
  font-weight: 700;
}

.avatar.large { width: 48px; height: 48px; }

.contact-copy { min-width: 0; }
.contact-copy strong, .contact-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-copy strong { font-size: 14px; }
.contact-copy span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.contact-copy .contact-property { color: var(--green); font-weight: 800; }
.contact-copy .contact-dates { color: #6d6557; font-size: 10px; }
.contact-copy .contact-phone { font-size: 10px; }
.contact-copy .source-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 5px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
  vertical-align: 1px;
}

.chat-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.empty-state {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 40px;
  text-align: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(30,118,85,.06), transparent 28%),
    linear-gradient(#fbfcfb, #f6f9f7);
}

.empty-state p { max-width: 440px; margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.empty-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #cce2d7;
  border-radius: 22px;
  font-weight: 900;
}

.active-chat {
  height: 100%;
  min-height: 0;
  /* Colonne flexible, PAS une grille a rangees numerotees.
     Une grille attribue ses rangees par POSITION, aux seuls enfants visibles :
     masquer la fiche reservation (cas des prestataires de menage) decalait tout
     d'un cran, la liste des messages heritait d'une rangee « auto » et poussait
     le composeur hors du cadre. Ici chaque enfant garde sa taille propre et seule
     la liste absorbe l'espace restant, quels que soient les elements masques. */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.active-chat > * { flex: 0 0 auto; }

.active-chat > .message-list {
  flex: 1 1 0;
  min-height: 0;
  height: auto;
  max-height: none;
}

.chat-header {
  min-height: 94px;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

/* Visé par sa classe et non par sa position : `div:nth-child(2)` désignait
   l'avatar dès qu'un élément était inséré avant lui dans l'en-tête. */
.chat-header > .chat-identity { min-width: 0; flex: 1; }
.chat-header h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 21px; }
.chat-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.chat-header .chat-property {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}
.chat-header .chat-stay-dates { color: #6d6557; font-size: 11px; }
.chat-header .chat-technical { font-size: 10px; }
.chat-actions { display: flex; align-items: center; gap: 9px; }
.chat-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(230px, 22vw);
  padding: 0 9px;
  color: var(--muted);
  background: var(--canvas);
  border: 1px solid transparent;
  border-radius: 9px;
}
.chat-search:focus-within { background: #fff; border-color: #82af9d; }
.chat-search input {
  width: 100%;
  min-width: 0;
  padding: 9px 0;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 12px;
}
.live-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 9px;
  padding-left: 9px;
  border-left: 1px solid var(--line);
}
.live-status::before {
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  background: #d3a653;
}
.live-status.live { color: var(--green-2); }
.live-status.live::before { background: #36a66f; box-shadow: 0 0 0 3px rgba(54,166,111,.12); }

.message-list {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #789c8d #e8efeb;
  padding: 18px 14px;
  background:
    linear-gradient(rgba(247,249,248,.91), rgba(247,249,248,.91)),
    radial-gradient(circle, #c9d8d1 1px, transparent 1px);
  background-size: auto, 22px 22px;
}

.message-list::-webkit-scrollbar { width: 13px; }
.message-list::-webkit-scrollbar-track {
  background: #e8efeb;
  border-left: 1px solid #d8e3dd;
}
.message-list::-webkit-scrollbar-thumb {
  background: #789c8d;
  border: 3px solid #e8efeb;
  border-radius: 999px;
}
.message-list::-webkit-scrollbar-thumb:hover { background: var(--green); }

.chat-notice {
  max-width: 520px;
  margin: 0 auto 20px;
  padding: 9px 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  text-align: center;
  font-size: 11px;
}

.message-row {
  max-width: 100%;
  margin: 0 0 12px;
}
.message-row.outgoing { margin-left: auto; }
.message-row.incoming { margin-right: auto; }
.message-author {
  margin: 0 8px 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 11px 13px 8px;
  box-shadow: 0 3px 10px rgba(34,75,57,.06);
  line-height: 1.45;
  white-space: pre-wrap;
}
.bubble.outgoing {
  margin-left: auto;
  background: #dff3e8;
  border-radius: 12px 4px 12px 12px;
}
.bubble.incoming {
  margin-right: auto;
  background: #fff;
  border: 1px solid #e4ebe7;
  border-radius: 4px 12px 12px 12px;
}
.bubble.failed { background: #fae7e6; }
.bubble-meta { display: flex; justify-content: flex-end; gap: 7px; margin-top: 5px; color: var(--muted); font-size: 10px; }
.bubble-meta .failed { color: var(--red); font-weight: 800; }
.bubble-text { overflow-wrap: anywhere; }
.message-attachment {
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.message-attachment span:last-child { min-width: 0; }
.message-attachment strong, .message-attachment small { display: block; }
.message-attachment small {
  max-width: 240px;
  margin-top: 2px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-icon {
  width: 36px;
  height: 36px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 9px;
  font-size: 19px;
  font-weight: 800;
}
.attachment-caption { margin-top: 8px; }

.composer {
  display: block;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 10px;
  align-items: stretch;
}

.composer textarea {
  resize: none;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  outline: 0;
}

.composer textarea:focus { border-color: #7ba895; box-shadow: 0 0 0 3px rgba(23,92,67,.08); }
.send-button { align-self: stretch; color: #fff; background: var(--green); border: 0; border-radius: 10px; padding: 0 18px; font-weight: 800; }
.attach-button {
  width: 44px;
  color: var(--green);
  background: var(--green-soft);
  border: 0;
  border-radius: 10px;
  font-size: 24px;
}
.attach-button:hover { background: #d9ece3; }
.attachment-preview {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 9px 10px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.attachment-copy { min-width: 0; }
.attachment-copy strong, .attachment-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-copy small { margin-top: 2px; color: var(--muted); }
.attachment-preview button {
  width: 30px;
  height: 30px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 20px;
}
.attachment-preview button:hover { background: #e7ece9; }
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.automation-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.tab { padding: 16px 4px 13px; color: var(--muted); background: #fff; border: 0; border-bottom: 3px solid transparent; font-weight: 800; font-size: 13px; }
.tab.active { color: var(--green); border-color: var(--green); }
.tab-content { min-height: 0; flex: 1; padding: 18px; overflow: hidden; }
#templatesTab, #schedulesTab, #aiConsignesTab { display: flex; flex-direction: column; }
/* la liste des messages programmés doit défiler à l'intérieur de l'onglet */
#schedulesTab .schedule-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding-right: 4px; }

.helper { margin: 12px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
code { color: var(--green); background: var(--green-soft); border-radius: 4px; padding: 2px 4px; }
.template-list, .schedule-list { flex: 1; }

.template-card, .schedule-card {
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.template-card:hover { border-color: #aacabd; box-shadow: 0 8px 24px rgba(28,75,56,.06); }
.template-card h3 { margin: 0 0 7px; font-size: 14px; }
.template-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-actions { display: flex; gap: 7px; margin-top: 12px; }
.small-button { flex: 1; padding: 8px; color: var(--green); background: var(--green-soft); border: 0; border-radius: 7px; font-size: 11px; font-weight: 800; }
.small-button.outline { background: #fff; border: 1px solid var(--line); }
.small-button.danger { color: var(--red); background: #faeeee; }

.queue-heading { padding-bottom: 14px; }
.queue-heading h2 { font-size: 20px; }
.icon-button { width: 34px; height: 34px; color: var(--green); background: var(--green-soft); border: 0; border-radius: 50%; font-size: 18px; }

.schedule-card { border-left: 3px solid var(--gold); }
.schedule-card.sent { border-left-color: var(--green-2); }
.schedule-card.failed { border-left-color: var(--red); }
.schedule-card.cancelled { opacity: .55; }
.schedule-card strong { display: block; font-size: 13px; }
.schedule-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.status-pill { display: inline-block; margin-top: 8px; padding: 4px 7px; border-radius: 999px; color: #7b5d26; background: #fbf0d9; font-size: 10px; font-weight: 800; }
.status-pill.sent { color: var(--green); background: var(--green-soft); }
.status-pill.failed { color: var(--red); background: #faeeee; }

dialog {
  width: min(560px, calc(100vw - 30px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(12,34,27,.48); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 16px; padding: 24px; }
.dialog-heading { justify-content: space-between; }
.close-button { width: 36px; height: 36px; color: var(--muted); background: var(--canvas); border: 0; border-radius: 50%; font-size: 22px; }
.dialog-card label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dialog-card input, .dialog-card textarea, .dialog-card select {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  outline: 0;
}
.dialog-card textarea { resize: vertical; }
.checkbox-row { grid-template-columns: auto 1fr !important; align-items: center; }
.checkbox-row input { width: auto; }
.dialog-actions { justify-content: flex-end; gap: 8px; }

.settings-card { max-height: calc(100vh - 60px); overflow-y: auto; }
.settings-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.settings-section-head { display: flex; align-items: center; justify-content: space-between; }
.settings-section-head h3 { margin: 0; font-family: Georgia, serif; font-size: 17px; color: var(--green); }
.switch-row { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.switch-row input { width: auto; }
.settings-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-test-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.settings-status { font-size: 12px; font-weight: 700; color: var(--muted); }
.settings-status.ok { color: var(--green); }
.settings-status.error { color: var(--red); }
.settings-advanced { border-top: 1px dashed var(--line); padding-top: 8px; }
.settings-advanced summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.settings-advanced .settings-inline { margin-bottom: 8px; }
.settings-advanced .switch-row { align-self: center; }
.reviews-columns { margin-top: 4px; font-size: 12px; color: var(--muted); }
.reviews-columns p { margin: 0 0 6px; }
.reviews-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.reviews-chips span { padding: 3px 8px; background: #fff; border: 1px solid var(--line); border-radius: 999px; font-weight: 700; color: var(--ink); }
.reviews-samples { color: var(--green); font-weight: 600; }

.ai-button { color: var(--gold); font-size: 18px; }
.ai-button:hover { background: #fbf3e2; }
.ai-button:disabled { opacity: .5; cursor: default; }

.schedule-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mode-tab {
  padding: 9px 8px;
  color: var(--muted);
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
}
.mode-tab.active { color: #fff; background: var(--green); border-color: var(--green); }

.ai-suggestion {
  margin: 0 16px 10px;
  padding: 12px 14px;
  background: #fbf3e2;
  border: 1px solid #e6d3a8;
  border-radius: 12px;
  flex: 0 0 auto;
}
.ai-suggestion-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ai-suggestion-label { color: var(--gold); font-size: 12px; font-weight: 800; }
.ai-suggestion p { margin: 0 0 10px; font-size: 13px; color: var(--ink); white-space: pre-wrap; }
.close-button.small { width: 24px; height: 24px; font-size: 16px; }

/* Fiche réservation (bandeau sous l'en-tête du chat) */
.reservation-strip {
  padding: 10px 20px;
  background: linear-gradient(#f3f8f5, #eef4f0);
  border-bottom: 1px solid var(--line);
}
.res-line { display: flex; align-items: center; gap: 10px; }
.res-line strong { font-size: 13px; color: var(--green); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-status {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  color: var(--green);
  background: var(--green-soft);
}
.res-status.cancelled, .res-status.expired, .res-status.declined { color: var(--red); background: #faeeee; }
.res-status.inquiry, .res-status.awaitingpayment { color: #7b5d26; background: #fbf0d9; }
.res-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }

/* Filtres boîte de réception (Messages) */
.msg-filters { display: flex; gap: 7px; margin: 0 16px 12px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px;
  color: var(--muted);
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip:hover { border-color: #82af9d; }
.chip.active { color: #fff; background: var(--green); border-color: var(--green); }

.clickable-card { cursor: pointer; }
.clickable-card .card-actions { pointer-events: auto; }

/* Parcours voyageur — éditeur d'étapes */
.journey-steps-head { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.journey-steps-head h3 { margin: 0; font-family: Georgia, serif; font-size: 16px; color: var(--green); }
.journey-steps { display: grid; gap: 10px; }
.journey-step {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.journey-step-top { display: flex; align-items: center; gap: 9px; }
.step-num {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}
.journey-step-top .js-label {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
}
.journey-step-top .js-label:focus { border-color: var(--green-2); box-shadow: var(--ring); }
.journey-step .js-timing { grid-template-columns: 1.4fr .8fr .8fr; }
.journey-step .js-content { grid-template-columns: 1fr 1.4fr; }

.property-picker { display: grid; gap: 8px; }
.picker-head { display: flex; align-items: center; justify-content: space-between; }
.picker-title { color: var(--muted); font-size: 12px; font-weight: 700; }
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 2px;
}
.tile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  min-height: 50px;
}
.tile:hover { border-color: #82af9d; }
.tile.selected { color: var(--green); background: var(--green-soft); border-color: var(--green); }
.tile-check {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: transparent;
  font-size: 12px;
  font-weight: 900;
}
.tile.selected .tile-check { color: #fff; background: var(--green); border-color: var(--green); }
.tile-name {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}
.recipient-card { gap: 10px; padding: 11px; background: var(--green-soft); border-radius: 10px; font-size: 13px; }
.preview-card { padding: 13px; background: var(--canvas); border: 1px solid var(--line); border-radius: 10px; }
.preview-card span { color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.preview-card p { margin: 7px 0 0; line-height: 1.5; white-space: pre-wrap; }

.empty {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.empty.compact { padding: 20px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 390px;
  padding: 13px 16px;
  color: #fff;
  background: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

/* Retour à la liste : n'a de sens que quand la conversation occupe l'écran. */
.retour-contacts { display: none; }
body.mode-compact .retour-contacts {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 44px;
  margin-left: -6px;
  color: var(--green);
  background: none;
  border: 0;
  font-size: 30px;
  line-height: 1;
}

/* Hamburger : trois traits qui se croisent quand le tiroir est ouvert. */
.hamburger {
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0 10px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
}
.hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .2s ease, opacity .15s ease;
}
body.menu-ouvert .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.menu-ouvert .hamburger span:nth-child(2) { opacity: 0; }
body.menu-ouvert .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 260px minmax(0, 1fr) 300px; }
}

@media (max-width: 940px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr) 270px; }
}

/* =========================================================
   Tablette et mobile
   =========================================================

   Les regles ne dependent PAS d'une media query mais des classes
   `.mode-tablette` et `.mode-compact`, posees sur <body> par app.js.

   Pourquoi : le bouton d'apercu doit pouvoir forcer l'affichage mobile depuis
   un ordinateur. Avec des media queries, il aurait fallu ecrire chaque regle
   deux fois — et la copie aurait derive de l'originale des la premiere
   retouche. Une seule classe, une seule verite.

   app.js applique ces classes d'apres `matchMedia`, donc le comportement
   automatique reste exactement celui d'une media query.
   ========================================================= */

.hamburger,
.volets,
.apercu-bouton { display: none; }
/* Le bouton d'apercu n'a de sens que sur un grand ecran : sur le telephone,
   l'affichage mobile EST deja ce qu'on veut verifier. */
body:not(.mode-compact) .apercu-bouton { display: inline-flex; }

/* ---------- Tablette : deux colonnes, actions en tiroir ---------- */

body.mode-tablette .app-shell { grid-template-columns: 260px minmax(0, 1fr); }

/* Le panneau d'automatisation devient un tiroir lateral : sur 820 px, trois
   colonnes laissent 240 px a la conversation, ou plus rien n'est lisible. */
body.mode-tablette .automation-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(380px, 88vw);
  height: 100dvh;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 34px rgba(12, 34, 27, .18);
  transform: translateX(100%);
  transition: transform .22s ease;
}
body.mode-tablette.actions-ouvertes .automation-panel { transform: none; }
/* Fermé, le tiroir reste focalisable : on tabulerait à travers un panneau
   entier d'éléments invisibles. `visibility` doit figurer dans la transition,
   sinon le tiroir disparaîtrait avant d'avoir fini de glisser. */
body.mode-tablette .automation-panel { visibility: hidden; transition: transform .22s ease, visibility .22s; }
body.mode-tablette.actions-ouvertes .automation-panel { visibility: visible; }
/* Sur tablette, seul le bouton Actions sert : les deux panneaux de gauche
   tiennent cote a cote. */
body.mode-tablette .volet[data-volet="contacts"],
body.mode-tablette .volet[data-volet="chat"] { display: none; }

/* ---------- Mobile : un seul volet a la fois ---------- */

body.mode-compact {
  overflow: hidden;
  /* 100dvh et non 100vh : la barre d'URL des navigateurs mobiles se retracte,
     et 100vh laissait la barre d'envoi 60 px sous le bas de l'ecran. */
  height: 100dvh;
}

body.mode-compact .topbar {
  /* La hauteur INCLUT le rembourrage (box-sizing: border-box). Avec
     `height: 56px` et un rembourrage haut de 59 px sur un iPhone à encoche, la
     zone de contenu tombait à zéro : la marque et le hamburger débordaient
     sous le bandeau vert, et une bande vide apparaissait en bas de l'écran. */
  height: calc(56px + env(safe-area-inset-top));
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  gap: 10px;
}
/* La marque n'a ni h1 ni p : c'est un strong et un span. Les deux règles
   précédentes ne visaient donc rien du tout. */
body.mode-compact .brand strong { font-size: 15px; }
body.mode-compact .brand span,
body.mode-compact .phone-priority { display: none; }

body.mode-compact .hamburger { display: flex; }

/* Le tiroir reprend la barre superieure telle quelle : aucun bouton n'est
   dupliqué, donc aucun ne peut etre oublie lors d'un ajout futur. */
body.mode-compact .connection {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  /* Fermé, le tiroir garderait ses quatorze contrôles dans l'ordre de
     tabulation : on les traverserait tous, invisibles, avant d'atteindre la
     liste de contacts. */
  visibility: hidden;
  width: min(300px, 84vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 64px) 14px calc(env(safe-area-inset-bottom) + 20px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(160deg, #123d31, #175c43);
  box-shadow: 14px 0 40px rgba(12, 34, 27, .32);
  transform: translateX(-100%);
  transition: transform .22s ease, visibility .22s;
}
body.mode-compact.menu-ouvert .connection { transform: none; visibility: visible; }
body.mode-compact .connection .button,
body.mode-compact .connection a.button {
  justify-content: flex-start;
  width: 100%;
  min-height: 46px;
  text-align: left;
}
body.mode-compact .connection select { width: 100%; min-width: 0; }

.menu-voile {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12, 34, 27, .5);
  backdrop-filter: blur(2px);
}

/* Le tiroir vit DANS la barre supérieure, qui porte `z-index: 3` et forme donc
   un contexte d'empilement : le `z-index: 60` du tiroir n'a de valeur qu'à
   l'intérieur de ce contexte, et la barre entière restait sous le voile à 50.
   Résultat, le menu ouvert était recouvert par son propre voile sombre.
   On remonte donc la barre elle-même, le temps que le menu soit ouvert. */
body.menu-ouvert .topbar { z-index: 60; }

/* Les trois panneaux occupent la meme case de la grille ; un seul est visible.
   Empiles verticalement, il fallait faire defiler tout le carnet d'adresses
   pour atteindre la conversation. */
body.mode-compact .app-shell {
  height: calc(100dvh - 56px - env(safe-area-inset-top));
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
  box-sizing: border-box;
}
body.mode-compact .contacts-panel,
body.mode-compact .chat-panel,
body.mode-compact .automation-panel {
  grid-area: 1 / 1;
  width: auto;
  height: 100%;
  min-height: 0;
  position: static;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}
body.mode-compact .contacts-panel,
body.mode-compact .chat-panel,
body.mode-compact .automation-panel { display: none; }
body.mode-compact[data-volet="contacts"] .contacts-panel,
body.mode-compact[data-volet="chat"] .chat-panel,
body.mode-compact[data-volet="actions"] .automation-panel { display: flex; }
body.mode-compact[data-volet="chat"] .chat-panel { display: block; }

/* Les DEUX modes, et non le seul mobile.
   En tablette, la barre était affichée mais restée dans le flux, sous une
   grille qui occupe déjà toute la hauteur, avec `body { overflow: hidden }` :
   elle tombait sous le pli, invisible et inatteignable. Comme c'était le seul
   accès au panneau Actions — lui-même sorti de l'écran — tout le panneau de
   droite (Modèles, Consignes IA, Programmés) devenait perdu sur iPad. */
body.mode-compact .volets,
body.mode-tablette .volets {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper);
  border-top: 1px solid var(--line);
}
body.mode-tablette .app-shell {
  height: calc(100dvh - 74px);
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
  box-sizing: border-box;
}
.volet {
  flex: 1;
  /* Positionné pour que le compteur, s'il sert un jour, se cale sur SON
     bouton et non sur la barre entière. */
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  /* 44 px minimum : en dessous, on rate la cible au pouce. */
  min-height: 58px;
  padding: 8px 4px;
  /* Pas `var(--muted)` : sur blanc il ne donne que 4,33:1, sous le seuil de
     lisibilité pour un libellé de 10 px. */
  color: #5c6b64;
  background: none;
  border: 0;
  font-size: 19px;
}
.volet span { font-size: 10px; font-weight: 700; }
.volet.actif { color: var(--green); background: var(--green-soft); }
.volet .volet-badge {
  position: absolute;
  transform: translate(16px, -4px);
  min-width: 16px;
  padding: 1px 4px;
  color: #fff;
  background: var(--red, #c0392b);
  border-radius: 999px;
  font-size: 9px;
}

/* En-tete de conversation : le retour est indispensable, la barre du bas ne
   suffit pas — on revient a la liste des dizaines de fois par jour. */
body.mode-compact .chat-header { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
body.mode-compact .chat-header h2 { font-size: 16px; }
body.mode-compact .chat-actions { width: 100%; flex-wrap: wrap; }
body.mode-compact .chat-search { flex: 1; width: auto; min-width: 120px; }
body.mode-compact .chat-stay-dates,
body.mode-compact .live-status { display: none; }

/* La zone d'ecriture doit rester atteignable au pouce, clavier ouvert. */
body.mode-compact .composer { padding: 8px 10px; }
/* Quatre colonnes, pas trois : la rangée porte quatre éléments visibles —
   « ＋ », « ✨ », la zone de texte et « Envoyer ». Avec trois colonnes, le
   bouton Envoyer basculait sur une deuxième ligne et la zone de texte se
   retrouvait coincée à droite. */
body.mode-compact .composer-row { grid-template-columns: auto auto 1fr auto; gap: 6px; }
body.mode-compact .send-button { padding: 0 14px; }
body.mode-compact .composer textarea { min-height: 44px; }

/* Les rangees d'onglets debordent : on les fait defiler horizontalement
   plutot que de les empiler sur trois lignes.

   `display: flex` est indispensable : ces barres sont des GRILLES a colonnes
   fixes (`repeat(4, 1fr)` pour six onglets), et sur une grille `flex-wrap` et
   `flex: 0 0 auto` n'ont aucun effet — les six onglets restaient repartis sur
   deux rangees bancales, dont une a moitie vide. */
/* `.contact-filters` est volontairement ABSENT de cette liste : c'était déjà
   une grille à une seule colonne, donc des filtres empilés pleine largeur — la
   bonne disposition sur téléphone. Le passer en bande défilante mettait trois
   listes déroulantes côte à côte sur 110 px chacune, où « Arrivées des 30
   derniers jours » se coupait au septième caractère. */
body.mode-compact .source-tabs,
body.mode-compact .automation-tabs,
body.mode-tablette .source-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
body.mode-compact .source-tabs::-webkit-scrollbar,
body.mode-compact .automation-tabs::-webkit-scrollbar,
body.mode-tablette .source-tabs::-webkit-scrollbar { display: none; }
/* `flex: 0 0 auto` doit valoir AUSSI en tablette : sans lui, les six onglets se
   comprimaient à 40 px dans une colonne de 260 px et rien ne défilait.
   44 px et non 40 : c'est le seuil en dessous duquel on rate la cible. */
body.mode-compact .source-tab,
body.mode-compact .tab,
body.mode-tablette .source-tab { flex: 0 0 auto; min-height: 44px; }

/* ---------- Fenetres modales ---------- */

/* En plein ecran : une fenetre de 560 px centree sur 390 px laissait ses bords
   hors champ, et le bouton de fermeture devenait inatteignable. */
body.mode-compact dialog,
body.mode-compact dialog.wide {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  border-radius: 0;
}
body.mode-compact .dialog-card,
body.mode-compact .settings-card,
body.mode-compact .logs-card {
  max-height: 100dvh;
  padding: 16px;
  padding-top: calc(env(safe-area-inset-top) + 16px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 24px);
  overflow-y: auto;
}
/* Le titre et la croix restent visibles pendant le defilement.
   `top` doit être POSITIF : une valeur négative autorisait l'en-tête à se
   caler au-dessus de la zone visible, où il était découpé par le débordement.
   Sur iPhone à encoche, la croix de fermeture devenait alors inatteignable dès
   qu'on faisait défiler — exactement le défaut que cette règle doit éviter.
   La marge négative annule le rembourrage haut de la fiche, et le rembourrage
   de l'en-tête reprend la garde de l'encoche. */
body.mode-compact .dialog-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: calc((env(safe-area-inset-top) + 16px) * -1) -16px 4px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
body.mode-compact .dialog-actions { flex-wrap: wrap; }
body.mode-compact .dialog-actions .button { flex: 1; min-width: 130px; min-height: 46px; }

/* Toutes les grilles de reglages passent sur une colonne. */
/* `.checkbox-row` est exclu : sa grille `auto 1fr` place la case à cocher À
   CÔTÉ de son libellé. En une colonne, la case passait au-dessus du texte. */
body.mode-compact .settings-inline { grid-template-columns: 1fr !important; }
body.mode-compact .settings-inline { display: grid; gap: 10px; }
body.mode-compact .settings-inline > * { width: 100%; }

/* Les tableaux larges defilent dans leur propre cadre : sans cela, c'est la
   page entiere qui glisse lateralement et plus rien n'est aligne. */
body.mode-compact .auto-row,
body.mode-compact .recipient-card { flex-wrap: wrap; gap: 8px; }
body.mode-compact .row-actions { width: 100%; }
body.mode-compact .row-actions .button { flex: 1; }

/* ---------- Confort tactile, commun aux deux formats ---------- */

body.mode-compact .button,
body.mode-tablette .button,
body.mode-compact .close-button {
  /* 36 px pour la croix de fermeture : trop petit pour un pouce. */
  min-height: 44px;
}
body.mode-compact .close-button { width: 44px; height: 44px; }

/* 16 px minimum : en dessous, iOS zoome automatiquement a chaque saisie et
   l'utilisateur doit repincer l'ecran apres chaque champ. */
body.mode-compact input,
body.mode-compact textarea,
body.mode-compact select,
body.mode-compact .dialog-card input,
body.mode-compact .dialog-card textarea,
body.mode-compact .dialog-card select { font-size: 16px; }

/* ---------- Corrections ciblees, relevees a l'inventaire ---------- */

/* Le calendrier ne se compresse pas : sept colonnes sur 390 px donnent 55 px
   par jour. On lui laisse sa largeur et on le fait defiler lateralement, dans
   son propre cadre — comprimer aurait rendu les reservations illisibles. */
body.mode-compact .calendar-body { overflow-x: auto; }
body.mode-compact .cal-grid,
body.mode-compact .cal-week { min-width: 620px; }
body.mode-compact .calendar-card { max-height: 100dvh; }
body.mode-compact .calendar-toolbar,
body.mode-compact .calendar-filters { flex-wrap: wrap; }
body.mode-compact .calendar-filters select { flex: 1; min-width: 140px; }

/* Grilles a trois colonnes et plus : une seule colonne, ou deux quand le
   contenu est un chiffre court. */
body.mode-compact .logs-filters,
body.mode-compact .cleaning-rule-head,
body.mode-compact .sched-state,
body.mode-compact .js-timing { grid-template-columns: 1fr; }
body.mode-compact .auto-grid { grid-template-columns: repeat(2, 1fr); }
body.mode-compact .tile-grid { grid-template-columns: 1fr; }

/* Defilements imbriques : sur ecran tactile, une liste qui defile a
   l'interieur d'une fenetre qui defile elle-meme piege le doigt — on ne sait
   plus lequel des deux bouge. Une seule zone de defilement, celle du dialogue. */
body.mode-compact .auto-list,
body.mode-compact .tile-grid,
body.mode-compact .owner-group-members,
body.mode-compact .reviews-sent-list,
body.mode-compact .logs-list,
body.mode-compact .prompt-preview {
  max-height: none;
  overflow: visible;
}

/* La barre de defilement forcee a 13 px prend une largeur precieuse et ne sert
   a rien au doigt. */
body.mode-compact .message-list { overflow-y: auto; }
body.mode-compact .message-list::-webkit-scrollbar { width: 0; }

/* Le message d'alerte debordait : 390 px de large ancres a 22 px du bord droit
   sortaient de l'ecran par la gauche, et faisaient glisser toute la page. */
body.mode-compact .toast {
  left: 12px;
  right: 12px;
  bottom: calc(70px + env(safe-area-inset-bottom));
  max-width: none;
}

/* Champs dont la taille est fixee par un identifiant : le selecteur de classe
   ne suffit pas a les ramener a 16 px, et iOS zoome des qu'on les touche. */
body.mode-compact #scopeNumbers,
body.mode-compact #toneInstructions,
body.mode-compact #toneLearnedStyle,
body.mode-compact .draft-bar textarea,
body.mode-compact .draft-card textarea,
body.mode-compact .cleaning-rule textarea,
body.mode-compact .role-select,
body.mode-compact .chat-search input,
body.mode-compact .contact-filters select,
body.mode-compact .calendar-filters select { font-size: 16px; }

/* Cibles tactiles. Les petits boutons d'action descendaient a 20-31 px : on
   rate la cible, et sur une liste de brouillons on touche le voisin. */
body.mode-compact .icon-button,
body.mode-compact .small-button,
body.mode-compact .chip,
body.mode-compact .mode-tab,
body.mode-compact .tone-tab,
body.mode-compact .row-actions .button,
body.mode-compact .log-actions .button,
body.mode-compact .draft-card-actions .button,
body.mode-compact .draft-bar-actions .button,
body.mode-compact .attachment-preview button,
body.mode-compact .rule-remove { min-height: 44px; }
body.mode-compact .icon-button,
body.mode-compact .attachment-preview button { min-width: 44px; }
/* Ceux-ci sont des elements de texte : les etirer a 44 px casserait la ligne.
   On elargit la zone touchable par le remplissage, sans changer le rythme. */
body.mode-compact .translate-button { padding: 8px 12px; }
body.mode-compact .log-toggle { padding: 8px 0; }
body.mode-compact .cal-chip { padding: 6px 8px; }

/* Les deux colonnes de la fenetre Diffusion : 220 px chacune ne tiennent pas
   cote a cote sur 390 px. */
.colonne-selection { flex: 1; min-width: 220px; }
body.mode-compact .colonne-selection { min-width: 0; }

/* ---------- Cadre d'apercu (bouton de test) ---------- */

/* Le mode force ne se contente pas d'appliquer les regles : il ramene la page
   a la largeur reelle de l'appareil. Verifier une mise en page mobile sur
   1920 px ne prouve rien. */
body.apercu-force {
  /* `position: relative` est indispensable : sans lui, les éléments passés en
     `absolute` ci-dessous prennent pour référence le viewport RÉEL, pas le
     cadre. Le voile noircissait alors les 1920 px de l'écran et la barre du
     bas s'étalait d'un bord à l'autre, hors du cadre. */
  position: relative;
  /* La bordure du cadre s'ajoute à la largeur : sans ce complément, un aperçu
     annoncé à 390 px n'offrait que 370 px de contenu. */
  width: calc(var(--apercu-largeur) + 20px);
  max-width: 100vw;
  height: var(--apercu-hauteur);
  max-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  border: 10px solid #1d2b26;
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(12, 34, 27, .35);
}
body.apercu-force.mode-compact .app-shell { height: calc(var(--apercu-hauteur) - 56px); }
body.apercu-force.mode-tablette .app-shell { height: calc(var(--apercu-hauteur) - 74px); }
body.apercu-force .connection,
body.apercu-force .automation-panel,
body.apercu-force .volets,
body.apercu-force .menu-voile { position: absolute; }
/* Les fenêtres modales échappent au cadre : `showModal()` les place dans le
   « top layer », dont la référence est toujours le viewport réel, quoi qu'on
   écrive ici. L'aperçu montre donc fidèlement les panneaux et la navigation,
   mais pas les fenêtres — celles-ci se vérifient sur l'appareil. */

/* =========================================================
   Modernisation — ergonomie, profondeur & micro-interactions
   ========================================================= */

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Focus clavier visible et homogène (accessibilité) */
:where(button, a, input, textarea, select, .contact-row, .tile, .source-tab, .tab, .mode-tab):focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Barre supérieure : légère profondeur pour la détacher */
.topbar {
  position: relative;
  z-index: 3;
  box-shadow: 0 2px 16px rgba(18, 61, 49, .18);
}

/* Boutons : profondeur + pression tactile */
.button {
  transition: transform .15s ease, box-shadow .18s ease, background .18s ease, opacity .15s ease;
  will-change: transform;
}
.button.primary { box-shadow: 0 4px 14px rgba(23, 92, 67, .22); }
.button.primary:hover { background: var(--green-2); box-shadow: 0 9px 22px rgba(23, 92, 67, .28); }
.button.secondary:hover { background: #d8ece1; }
.button.ghost:hover { background: rgba(255, 255, 255, .18); }
.button:active { transform: translateY(0) scale(.98); }
.icon-button, .close-button, .attach-button, .send-button, .small-button {
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .06s ease;
}
.icon-button:hover, .close-button:hover, .attach-button:hover { background: #eef4f1; }
.send-button:hover { background: var(--green-2); }
.small-button:active, .send-button:active, .attach-button:active { transform: scale(.96); }

/* Champs de saisie : survol + focus cohérents partout */
.dialog-card input, .dialog-card textarea, .dialog-card select, .contact-filters select {
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.dialog-card input:hover, .dialog-card textarea:hover, .dialog-card select:hover,
.contact-filters select:hover { border-color: #b9cdc4; }
.dialog-card input:focus, .dialog-card textarea:focus, .dialog-card select:focus,
.contact-filters select:focus, .connection select:focus {
  border-color: var(--green-2);
  box-shadow: var(--ring);
}

/* Lignes de contacts / réservations */
.contact-row { transition: background .14s ease, box-shadow .14s ease, transform .06s ease; }
.contact-row:active { transform: scale(.995); }

/* Cartes (modèles, consignes, logements, programmés) : profondeur au survol */
.template-card, .schedule-card {
  transition: box-shadow .18s ease, transform .12s ease, border-color .15s ease;
}
.template-card:hover, .schedule-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Vignettes de logements & onglets */
.tile, .source-tab, .tab, .mode-tab {
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .06s ease;
}
.tile:hover { box-shadow: var(--shadow-sm); }
.tile:active { transform: scale(.97); }

/* Sections de réglages : légère profondeur au survol */
.settings-section { transition: box-shadow .18s ease, border-color .15s ease; }
.settings-section:hover { box-shadow: var(--shadow-sm); }

/* Fenêtres pop-up : ouverture animée */
dialog[open] { animation: dialogIn .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}
dialog::backdrop { animation: backdropIn .22s ease; }
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

/* Statuts en pastille : petite touche moderne */
.status-pill, .source-badge, .unread-badge { letter-spacing: .01em; }

/* Bandeau suggestion IA : petite animation d'arrivée */
.ai-suggestion:not(.hidden) { animation: dialogIn .2s ease; }

/* Toast : apparition plus fluide (si non déjà géré) */
.toast { transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .25s ease; }

/* Dégradés subtils pour un rendu plus riche et moderne */
.button.primary { background: linear-gradient(135deg, #1f7a58, var(--green)); }
.button.primary:hover { background: linear-gradient(135deg, #24895f, #1a6b4e); }
.send-button { background: linear-gradient(135deg, #1f7a58, var(--green)); }
.send-button:hover { background: linear-gradient(135deg, #24895f, #1a6b4e); }
.mode-tab.active { background: linear-gradient(135deg, var(--green-2), var(--green)); }
.avatar { box-shadow: 0 3px 9px rgba(20, 60, 45, .20); }
.avatar.large { box-shadow: 0 5px 14px rgba(20, 60, 45, .24); }

/* Respect des préférences de réduction d'animation */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Messagerie Hostaway : badges de canal + pastille non-lu ---- */
.channel-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 7px;
  color: #fff;
  background: var(--muted);
  border-radius: 999px;
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
  vertical-align: 1px;
  letter-spacing: .01em;
}
.channel-badge.airbnb { background: #e35d5b; }
.channel-badge.bookingcom, .channel-badge.booking { background: #2b5fb3; }
.channel-badge.expedia { background: #f2b134; color: #3a2c00; }
.channel-badge.vrbo, .channel-badge.homeaway { background: #2b8a89; }
.channel-badge.direct { background: var(--green-2); }
.channel-badge.email { background: #5a6b8c; }
.channel-badge.sms { background: #7b5aa6; }

.unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  background: var(--green-2);
  border: 2px solid var(--paper);
  border-radius: 50%;
}
.contact-row .avatar { position: relative; overflow: visible; }

.contact-copy .contact-preview {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Badge d'origine dans une bulle Hostaway */
.origin-badge {
  padding: 0 6px;
  color: #fff;
  background: var(--muted);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .01em;
}
.origin-badge.airbnb { background: #e35d5b; }
.origin-badge.bookingcom, .origin-badge.booking { background: #2b5fb3; }
.origin-badge.email { background: #5a6b8c; }
.origin-badge.sms { background: #7b5aa6; }
.origin-badge.channel { background: var(--green-2); }
.origin-badge.whatsapp { background: #25d366; color: #08351f; }

/* Choix du canal d'envoi (conversations Hostaway) */
.channel-choice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}
.channel-choice-label { color: var(--muted); font-weight: 800; }
.channel-opt { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); font-weight: 600; cursor: pointer; }
.channel-opt input { accent-color: var(--green-2); }
.channel-opt strong { font-weight: 800; }
.channel-opt em { color: var(--muted); font-style: normal; font-size: 11px; }
.channel-opt.disabled { opacity: .45; cursor: not-allowed; }

/* ---- Calendrier ---- */
.calendar-dialog { width: min(1080px, calc(100vw - 24px)); }
.calendar-card { gap: 14px; max-height: calc(100vh - 48px); }
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-nav strong { margin-left: 6px; font-size: 15px; text-transform: capitalize; }
.calendar-views { display: flex; gap: 6px; }
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}
.icon-button:hover { background: var(--canvas); }
.calendar-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.calendar-filters select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}
.calendar-body { overflow: auto; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.cal-weekday {
  padding: 8px 6px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.cal-cell {
  min-height: 92px;
  padding: 5px 6px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell.muted { background: #fafcfb; }
.cal-cell.muted .cal-daynum { color: #b6c3bc; }
.cal-cell.today { background: var(--green-soft); }
.cal-daynum { font-size: 12px; font-weight: 800; color: var(--ink); }
.cal-cell.today .cal-daynum {
  color: #fff;
  background: var(--green-2);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-chips { display: flex; flex-direction: column; gap: 3px; }
.cal-chips.column { min-height: 60px; }
.cal-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
}
.cal-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip:hover { filter: brightness(.97); }
.cal-chip .cal-chip-tag { font-style: normal; font-weight: 900; opacity: .8; }
.cal-chip.airbnb { background: #fbe4e3; color: #a3302e; }
.cal-chip.bookingcom, .cal-chip.booking { background: #e2ecfb; color: #234f96; }
.cal-chip.expedia { background: #fbf0d5; color: #7b5d1a; }
.cal-chip.vrbo, .cal-chip.homeaway { background: #d9f0ef; color: #1c5d5c; }
.cal-chip.direct { background: var(--green-soft); color: var(--green); }
.cal-chip.cancelled { opacity: .5; text-decoration: line-through; }
.cal-more { font-size: 10px; font-weight: 800; color: var(--muted); padding-left: 4px; }
.cal-legend { margin: 8px 2px 0; color: var(--muted); font-size: 11px; }

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.cal-week-col { background: var(--paper); min-height: 160px; padding: 6px; }
.cal-week-col.today { background: var(--green-soft); }
.cal-week-head { font-size: 12px; font-weight: 800; margin-bottom: 6px; text-align: center; }
.cal-empty { color: #c2cec8; font-size: 12px; }

.cal-list { display: flex; flex-direction: column; gap: 8px; }
.cal-list-row {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.cal-list-row.cancelled { opacity: .6; }
.cal-list-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-list-main strong { font-size: 14px; }
.cal-list-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12px; font-weight: 600; }
.cal-list-row .button.small { justify-self: start; padding: 7px 12px; font-size: 12px; }

@media (max-width: 720px) {
  .cal-cell { min-height: 64px; }
  .calendar-toolbar { flex-direction: column; align-items: stretch; }
}

/* ---- Paramètres : indice + liste des avis 5★ envoyés ---- */
.settings-hint { color: var(--muted); font-weight: 600; font-size: 11px; }

.reviews-sent-dialog { width: min(680px, calc(100vw - 24px)); }
.reviews-sent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow: auto;
  padding-right: 2px;
}
.reviews-sent-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.reviews-sent-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.reviews-sent-head strong { font-size: 13px; }
.reviews-sent-meta { color: var(--muted); font-size: 11px; font-weight: 600; }
.reviews-sent-body {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Bannière statut + aperçu + badges (Voyageurs avis 5★) */
.reviews-banner {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--canvas);
}
.reviews-banner:empty { display: none; }
.reviews-banner-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reviews-banner-pill { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.reviews-banner-pill.on { color: var(--green); background: var(--green-soft); }
.reviews-banner-pill.off { color: var(--red); background: #faeeee; }
.reviews-banner-pill.warn { color: #7b5d26; background: #fbf0d9; }
.reviews-banner-meta { color: var(--muted); font-size: 11px; font-weight: 600; }
.reviews-banner-link { color: var(--green); font-size: 11px; font-weight: 700; word-break: break-all; }
.reviews-banner-hint { margin: 0; color: var(--muted); font-size: 11px; }

.rating-stars { color: var(--gold); font-size: 12px; letter-spacing: 1px; }
.reviews-status-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; font-style: normal; vertical-align: 1px; }
.contact-copy .contact-phone .reviews-status-badge { float: right; }
.reviews-status-badge.sent { color: var(--green); background: var(--green-soft); }
.reviews-status-badge.pending { color: #7b5d26; background: #fbf0d9; }
.reviews-status-badge.nophone { color: var(--muted); background: #eef2f0; }

.reviews-preview { display: grid; gap: 6px; }
.reviews-preview-head { color: var(--muted); font-size: 11px; font-weight: 800; }
.reviews-preview-bubble {
  padding: 12px 14px;
  border-radius: 12px 12px 12px 4px;
  background: var(--green-soft);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ---------- Écran de connexion ---------- */

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(30,118,85,.16), transparent 60%),
    var(--canvas);
}

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 20px;
  padding: 30px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { color: #fff; background: var(--green); border-color: transparent; }
.login-brand strong { display: block; font-family: Georgia, serif; font-size: 18px; }
.login-brand span { color: var(--muted); font-size: 12px; font-weight: 600; }

.login-form { display: grid; gap: 14px; }
.login-form h1 { margin: 0; font-family: Georgia, serif; font-size: 22px; color: var(--green); }
.login-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.login-form .field { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-form input {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  outline: 0;
}
.login-form input:focus { border-color: var(--green-2); box-shadow: var(--ring); }
.login-submit { width: 100%; justify-content: center; margin-top: 4px; }

.login-error {
  margin: 0;
  padding: 10px 12px;
  color: var(--red);
  background: #fbeceb;
  border: 1px solid #f0d3d1;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Panneau « envois automatiques » ---------- */

.auto-status { display: grid; gap: 12px; }

.auto-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #cfe5da;
}
.auto-banner.paused { color: #7b5d26; background: #fbf0d9; border-color: #ecdcb5; }
.auto-banner.error { color: var(--red); background: #fbeceb; border-color: #f0d3d1; }

.auto-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.auto-tile {
  display: grid;
  gap: 3px;
  padding: 12px;
  text-align: center;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.auto-tile strong { font-size: 20px; font-family: Georgia, serif; color: var(--green); }
.auto-tile span { color: var(--muted); font-size: 11px; font-weight: 700; }
.auto-tile.warn strong { color: var(--red); }

.auto-list { display: grid; gap: 6px; max-height: 210px; overflow-y: auto; }
.auto-row {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}
.auto-row .auto-row-main { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.auto-row .auto-row-note { color: var(--muted); font-size: 11px; }
.auto-row.failed { border-color: #f0d3d1; background: #fdf6f5; }
.auto-row.failed .auto-row-note { color: var(--red); }

.auto-section-title { margin: 0; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }

.webhook-url {
  display: block;
  padding: 9px 11px;
  background: var(--canvas);
  border: 1px dashed var(--line);
  border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--ink);
  word-break: break-all;
}

/* ---------- Journal d'activité ---------- */

/* La largeur est portée par une CLASSE, pas par une liste d'identifiants : ajouter
   une fenêtre large ne demande plus de penser à modifier cette règle — c'est
   exactement l'oubli qui rendait la fenêtre des brouillons trop étroite. */
dialog.wide { width: min(880px, calc(100vw - 32px)); }
.logs-card {
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.logs-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.logs-summary span {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  background: var(--canvas);
  border: 1px solid var(--line);
}
.logs-summary span.error { color: var(--red); background: #fbeceb; border-color: #f0d3d1; }
.logs-summary span.warn { color: #7b5d26; background: #fbf0d9; border-color: #ecdcb5; }
.logs-summary span.info { color: var(--green); background: var(--green-soft); border-color: #cfe5da; }

.logs-filters { display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px; align-items: center; }
.logs-filters select, .logs-filters input {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  outline: 0;
}
.logs-filters input:focus, .logs-filters select:focus { border-color: var(--green-2); box-shadow: var(--ring); }

.logs-list { display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; }

/* Les brouillons se lisent en entier : la liste prend la hauteur disponible et
   les zones de texte s'ajustent à leur contenu (voir autoSizeTextarea). */
#draftsList { max-height: none; overflow: visible; }

.log-row {
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 10px;
  font-size: 12px;
}
.log-row.info { border-left-color: var(--green); }
.log-row.warn { border-left-color: var(--gold); background: #fffdf7; }
.log-row.error { border-left-color: var(--red); background: #fdf6f5; }

.log-head { display: flex; align-items: baseline; gap: 8px; }
.log-head time { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.log-cat {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--canvas);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}
.log-msg { flex: 1; line-height: 1.5; }
.log-toggle { border: 0; background: none; color: var(--green); font-size: 11px; font-weight: 800; padding: 0; }

.log-detail { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line); display: grid; gap: 5px; }
.log-detail dl { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 3px 10px; margin: 0; }
.log-detail dt { color: var(--muted); font-size: 11px; font-weight: 800; }
.log-detail dd { margin: 0; font-size: 11px; word-break: break-word; }
.log-detail dd.raw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--red); }
.log-actions { display: flex; gap: 8px; margin-top: 8px; }
.log-actions .button { padding: 6px 11px; font-size: 11px; }

.log-fix {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--green-soft);
  border: 1px solid #cfe5da;
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
}

/* Fiche d'un message : état + frise */
.sched-card { display: grid; gap: 10px; }
.sched-state { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sched-state div {
  padding: 10px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.sched-state dt { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.sched-state dd { margin: 3px 0 0; font-size: 12px; font-weight: 700; }
.status-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-pill.sent { color: var(--green); background: var(--green-soft); }
.status-pill.pending { color: #7b5d26; background: #fbf0d9; }
.status-pill.failed { color: var(--red); background: #fbeceb; }
.status-pill.cancelled, .status-pill.processing { color: var(--muted); background: #eef2f0; }

.channel-note { flex-basis: 100%; color: #7b5d26; font-size: 11px; font-weight: 700; }


/* ---------- Prestataires de ménage ---------- */

.cleaner-form { display: grid; gap: 10px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }

.cleaner-row, .group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}
.cleaner-row.inactive, .group-row.inactive { opacity: .55; }
.cleaner-row strong, .group-row strong { font-weight: 800; }
.cleaner-row .meta, .group-row .meta { color: var(--muted); font-size: 11px; }
.group-row { cursor: pointer; }
.group-row:hover { border-color: var(--green-2); box-shadow: var(--shadow-sm); }
.row-actions { display: flex; gap: 6px; }
.row-actions .button { padding: 5px 10px; font-size: 11px; }

.cleaning-rule {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.cleaning-rule-head { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; }
.cleaning-rule textarea { min-height: 96px; font-size: 12px; line-height: 1.5; }
.cleaning-rule .rule-remove { color: var(--red); background: #fbeceb; border: 0; border-radius: 8px; padding: 6px 10px; font-size: 11px; font-weight: 800; }

.plan-preview {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: var(--green-soft);
  border: 1px solid #cfe5da;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}


/* ---------- Brouillons de réponse ---------- */

.drafts-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.draft-bar {
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  background: #fffdf7;
  border-top: 1px solid #ecdcb5;
  border-bottom: 1px solid #ecdcb5;
}
.draft-bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.draft-bar-head strong { color: #7b5d26; font-size: 12px; font-weight: 800; }
.draft-bar-head span { color: var(--muted); font-size: 11px; }
.draft-bar textarea {
  max-height: 32vh;
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ecdcb5;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  outline: 0;
}
.draft-bar textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(198,147,66,.18); }
.draft-bar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.draft-bar-actions .button { padding: 7px 12px; font-size: 12px; }

.draft-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  font-size: 12px;
}
.draft-card.cleaner { border-left-color: var(--green); }
.draft-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.draft-card-head strong { font-weight: 800; }
.draft-card-head time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.draft-incoming {
  padding: 8px 10px;
  background: var(--canvas);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.draft-card textarea {
  width: 100%;
  min-height: 72px;
  overflow-y: hidden;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
  outline: 0;
}
.draft-card textarea:focus { border-color: var(--green-2); box-shadow: var(--ring); }
.draft-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.draft-card-actions .button { padding: 6px 11px; font-size: 11px; }
.audience-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  background: #fbf0d9;
  color: #7b5d26;
}
.audience-pill.cleaner { background: var(--green-soft); color: var(--green); }


/* ---------- Ton de l'IA par interlocuteur ---------- */

.tone-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tone-tab {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.tone-tab.active { color: #fff; background: var(--green); border-color: var(--green); }
.tone-tab:hover:not(.active) { border-color: var(--green-2); color: var(--green); }
.tone-tab .tone-tab-count { opacity: .7; font-weight: 600; }

#toneInstructions, #toneLearnedStyle {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: 0;
}
#toneInstructions:focus, #toneLearnedStyle:focus { border-color: var(--green-2); box-shadow: var(--ring); }
#toneLearnedStyle { background: var(--green-soft); border-color: #cfe5da; }

.prompt-safety {
  margin: 8px 0 0;
  padding: 11px 13px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  white-space: pre-wrap;
}

.prompt-preview {
  padding: 12px 14px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 40vh;
  overflow-y: auto;
}

/* ---------- Calendrier : entrées et sorties ---------- */

.cal-week-count { display: block; margin-top: 2px; font-size: 10px; font-weight: 700; color: var(--muted); }

.cal-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.cal-day-head strong { font-size: 13px; color: var(--green); text-transform: capitalize; }
.cal-day-head span { font-size: 11px; font-weight: 700; color: var(--muted); }
.cal-day-head:first-child { margin-top: 0; }

.cal-move {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.cal-move.in { color: var(--green); background: var(--green-soft); }
.cal-move.out { color: #7b5d26; background: #fbf0d9; }

.cal-list-row.in { border-left: 3px solid var(--green); }
.cal-list-row.out { border-left: 3px solid var(--gold); }


/* ---------- Traduction des messages ---------- */

.translate-button {
  margin-top: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  opacity: .55;
  transition: opacity .15s, border-color .15s, color .15s;
}
.message-row:hover .translate-button { opacity: 1; }
.translate-button:hover { border-color: var(--green-2); color: var(--green); }
/* Message qui n'a pas l'air français : le bouton se voit sans survol. */
.translate-button.suggested { opacity: 1; border-color: var(--green-2); color: var(--green); }

.bubble-translation {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.bubble-translation.loading { color: var(--muted); font-style: italic; }
.translation-tag {
  display: block;
  margin-bottom: 3px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--green);
}
.bubble.outgoing .translation-tag { color: #cfe5da; }
.bubble.outgoing .bubble-translation { border-top-color: rgba(255,255,255,.25); }


/* ---------- Diffusion ---------- */

.broadcast-result { margin-top: 14px; }
.broadcast-block { margin-bottom: 14px; }
.broadcast-block h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.broadcast-preview {
  padding: 10px 12px;
  margin-bottom: 7px;
  background: var(--green-soft);
  border: 1px solid #cfe5da;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.broadcast-preview strong { display: block; margin-bottom: 3px; color: var(--green); font-size: 11px; }

.broadcast-alert {
  padding: 9px 12px;
  margin-bottom: 6px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.5;
}
.broadcast-alert.error { color: #8a2d2d; background: #fdeaea; border: 1px solid #f3c9c9; }
.broadcast-alert.warn { color: #7b5d26; background: #fbf0d9; border: 1px solid #ecd9ac; }
.broadcast-alert.ok { color: var(--green); background: var(--green-soft); border: 1px solid #cfe5da; }

/* ---------- Groupes de propriétaires ---------- */

.owner-group-members {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px 12px;
  margin: 8px 0;
  padding: 9px 11px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 9px;
  max-height: 190px;
  overflow-y: auto;
}
.owner-group-members .switch-row { font-size: 12px; }

/* ---------- Avertissement dans les paramètres ---------- */

.settings-warning {
  margin: 8px 0 10px;
  padding: 10px 12px;
  background: #fbf0d9;
  border: 1px solid #ecd9ac;
  border-left: 3px solid var(--gold);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.55;
  color: #7b5d26;
}

/* ---------- Périmètre des réponses automatiques ---------- */

.scope-block {
  margin: 10px 0 14px;
  padding: 12px 14px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.scope-block h4,
.settings-section-head h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}
.scope-block select[multiple] {
  width: 100%;
  padding: 6px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
#scopeNumbers {
  width: 100%;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  resize: vertical;
}

/* ---------------------------------------------------------------------------
   Mode démonstration.
   Le bandeau est volontairement impossible à manquer : pendant un tournage,
   il doit être évident à l'écran qu'aucun message ne part réellement.
--------------------------------------------------------------------------- */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 18px;
  background: repeating-linear-gradient(
    45deg, #b91c1c, #b91c1c 14px, #991b1b 14px, #991b1b 28px
  );
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.demo-banner strong { font-weight: 700; }

#demoBannerCountdown {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.demo-banner .button.ghost {
  border-color: rgba(255, 255, 255, 0.6);
  color: #fff;
}

/* Second rideau : les photos et pièces jointes n'ont pas de nom à remplacer,
   on les floute donc. Le floutage se lève au survol, pour que l'exploitant
   puisse vérifier ce qu'il montre sans couper la démonstration. */
body.demo-flou .message-media img,
body.demo-flou .message-list img,
body.demo-flou .avatar img,
body.demo-flou img[src^="data:"],
body.demo-flou img[src^="blob:"] {
  filter: blur(10px);
  transition: filter 120ms ease;
}

body.demo-flou .message-media img:hover,
body.demo-flou .message-list img:hover {
  filter: blur(0);
}

/* Badge d'humeur d'un voyageur. Volontairement discret dans la liste : c'est
   un signal, pas une alarme — mais il doit se voir avant d'ouvrir la
   conversation. */
.contact-sentiment {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  margin-top: 2px;
}
.sentiment-fache { background: #fee2e2; color: #991b1b; }
.sentiment-mecontent { background: #ffedd5; color: #9a3412; }
.sentiment-content { background: #dcfce7; color: #166534; }

:root:not([data-theme="light"]) .sentiment-fache,
:root[data-theme="dark"] .sentiment-fache { background: #7f1d1d; color: #fecaca; }
:root:not([data-theme="light"]) .sentiment-mecontent,
:root[data-theme="dark"] .sentiment-mecontent { background: #7c2d12; color: #fed7aa; }
:root:not([data-theme="light"]) .sentiment-content,
:root[data-theme="dark"] .sentiment-content { background: #14532d; color: #bbf7d0; }

/* Rôle du correspondant, dans l'en-tête de conversation. Discret : c'est un
   réglage qu'on consulte souvent et qu'on modifie rarement. */
.role-select {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.role-source {
  font-size: 11px;
  opacity: 0.65;
  margin-left: 6px;
}

/* Bandeau de panne d'IA. Rouge uni, distinct des rayures du mode
   démonstration : ce n'est pas le même message. */
.ia-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 18px;
  background: #7f1d1d;
  color: #fff;
  font-size: 13px;
}
#iaBannerCompteur { margin-left: auto; opacity: 0.85; font-variant-numeric: tabular-nums; }
.ia-banner kbd, .settings-test-row kbd {
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: 0.7;
  margin-left: 4px;
}
