/* CRM : les écrans propres au CRM, par-dessus app.css. Uniquement ses
 * variables : aucune couleur ni aucun rayon nouveaux. */

/* Une liste d'appels se lit mieux sur une colonne étroite, même à l'écran.
 * Le bandeau des pages suit la même colonne pour que tout s'aligne à gauche. */
.content.crm-narrow { max-width: 860px; }
.subnav.crm-narrow { max-width: 860px; margin: 0 auto; }
.content.crm-wide { max-width: 1100px; }
.subnav.crm-wide { max-width: 1100px; margin: 0 auto; }

.crm-list { list-style: none; margin: 0; padding: 0; }
.crm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--grid);
}
.crm-row:last-child { border-bottom: none; }
/* Sans titre de carte, la première ligne colle au rebord comme le reste. */
.card > .crm-list:first-child > .crm-row:first-child { padding-top: 0; }
.card > .crm-list:first-child > .crm-row:last-child { padding-bottom: 0; }
.crm-main { flex: 1; min-width: 0; color: inherit; }
a.crm-main:hover { text-decoration: none; }
a.crm-main:hover .crm-name { color: var(--accent-strong); }
.crm-name { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.crm-meta { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.crm-contact {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-late { color: var(--danger); font-weight: 600; }
a.crm-call { flex: none; display: inline-block; }
a.crm-call:hover { text-decoration: none; }

.crm-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.crm-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 18px 0 2px;
}
.crm-group-title:first-child { margin-top: 0; }

.crm-message {
  background: var(--accent-wash);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 16px;
  font-size: 13.5px;
}
.crm-message-error { background: var(--surface); color: var(--danger); border-color: var(--danger); }

.crm-muted { color: var(--muted); font-size: 13px; }
.crm-note { color: var(--ink); font-size: 13px; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-grid .field .v { overflow-wrap: anywhere; }

/* fiche : appeler, puis noter l'appel */
.crm-callbar { margin-bottom: 14px; }
a.crm-call-big { display: inline-block; padding: 8px 16px; font-size: 13.5px; }
a.crm-call-big:hover { text-decoration: none; }
.crm-ask { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-2); }
.crm-call-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.crm-call-actions a:hover { text-decoration: none; }
.crm-hint {
  color: var(--ink-2);
  font-size: 13px;
  background: var(--accent-wash);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 0 0 12px;
}
.crm-blocked { color: var(--danger); font-weight: 600; margin: 0; }
.crm-fieldset { border: none; margin: 0 0 12px; padding: 0; min-width: 0; }
.crm-fieldset legend { color: var(--muted); font-size: 12px; margin-bottom: 6px; padding: 0; }
.crm-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.crm-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer;
}
.crm-choice:hover { border-color: var(--baseline); color: var(--ink); }
.crm-choice:has(input:checked) {
  border-color: var(--accent-strong);
  background: var(--accent-wash);
  color: var(--accent-strong);
  font-weight: 600;
}
.crm-choice:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.crm-choice input { margin: 0; accent-color: var(--accent-strong); }
.form-grid.crm-form-single { grid-template-columns: 1fr; }
.crm-submit { padding: 8px 16px; font-size: 13.5px; }
.crm-submit:disabled { opacity: 0.6; cursor: wait; }
.crm-form-status {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--accent-wash);
  color: var(--ink);
  font-size: 13.5px;
}
.crm-form-status.crm-form-error { background: var(--surface); color: var(--danger); border: 1px solid var(--danger); }
.crm-status-line { margin: 0; }
.crm-status-line + .crm-status-line { margin-top: 6px; }
.crm-warning { color: var(--ink-2); padding-top: 6px; border-top: 1px solid var(--border); }
.crm-section-hint { color: var(--muted); font-size: 12.5px; margin: -6px 0 10px; }
.crm-signal { margin: 0 0 8px; line-height: 1.5; }
.crm-source { margin: 0; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
/* Dossier de vente : une rubrique par titre, une idée par ligne. */
.crm-dossier h3 { margin: 14px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.crm-dossier h3:first-child { margin-top: 0; }
.crm-rich-line { margin: 0 0 4px; line-height: 1.5; overflow-wrap: anywhere; }

/* Tableau des prospects : la recherche prend la place qui reste. */
.crm-filters input[type="search"] { flex: 1 1 260px; min-width: 0; }
.crm-filters select { flex: 1 1 150px; min-width: 0; }
.crm-table td a { font-weight: 600; }

/* Un champ et son bouton sur une même ligne (fiche : contrat, attribution). */
.crm-inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.crm-inline-form label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; }
.crm-inline-form label > span { color: var(--muted); font-size: 12px; }
.crm-inline-form select, .crm-inline-form input { width: 100%; }

/* Équipe : la personne qu'on modifie; une case à cocher sur une ligne. */
table.data tr.crm-selected td { background: var(--accent-wash); }
.crm-table-hint { margin: 10px 0 0; }
.form-grid label.crm-check { flex-direction: row; align-items: center; gap: 8px; min-height: 32px; }
.form-grid label.crm-check > span { color: var(--ink-2); font-size: 13px; }
.form-grid label.crm-check input { width: auto; margin: 0; }
.crm-actions-wrap { flex-wrap: wrap; }

/* Importer : la liste des colonnes, le choix du fichier, les avertissements. */
.crm-columns { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }
.crm-columns summary { cursor: pointer; padding: 6px 0; }
.crm-columns table.data { margin-top: 6px; }
.crm-warning-line { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; }

/* En-tête de page : les boutons d'action à droite du titre (comme btn-new). */
.crm-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
a.btn-sm { display: inline-flex; align-items: center; text-decoration: none; }
a.btn-sm.primary:hover { text-decoration: none; }
.page-head .seg.crm-head-actions { gap: 0; }

/* Tableaux : un texte long tient sur une ligne; colonnes secondaires au large. */
.crm-clip {
  display: block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

/* Chaleur : l'œil va d'abord aux plus chauds. Rouge plein, puis les pastilles
   de l'application (rouge pâle, ambre, bleu pâle), puis gris pour « Très froid ». */
.badge.crm-heat-very-hot { color: var(--surface); background: var(--danger); border-color: transparent; }
.badge.crm-heat-very-cold { color: var(--muted); }

/* Qui le voit : moi seulement, tout le monde ou les personnes cochées. */
.crm-visibility { margin-top: 12px; }
.crm-radio, .crm-check-line { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.crm-radio input, .crm-check-line input { margin: 0; }
.crm-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 16px;
  margin: 4px 0 0 24px;
}
.crm-clip.crm-name-link { max-width: 210px; color: var(--accent-strong); font-weight: 600; }
.crm-clip.crm-clip-short { max-width: 120px; color: inherit; }
.crm-phone-sub { display: none; }
/* Suivi : une carte par vendeur; un clic filtre la liste. */
.kpi.crm-person { display: flex; flex-direction: column; gap: 10px; padding: 0; }
.crm-person-pick {
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  padding: 14px 16px;
  cursor: pointer;
  color: inherit;
}

/* Importer : le bouton d'abord, puis la notice repliée en bas. */
.crm-file-input { font: inherit; color: var(--ink-2); max-width: 100%; }
.crm-file-input::file-selector-button {
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent-strong);
  border: 0;
  border-radius: var(--radius);
  padding: 9px 16px;
  margin-right: 12px;
  cursor: pointer;
}
.crm-howto > summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.crm-howto[open] > summary { margin-bottom: 12px; }

/* Importer : la notice et le texte à donner à une IA. */
.crm-guide { margin: 0 0 14px; padding-left: 20px; line-height: 1.55; }
.crm-subtitle { margin: 22px 0 6px; font-size: 14px; }
.crm-guide li { margin-bottom: 8px; }
.crm-instructions {
  width: 100%;
  box-sizing: border-box;
  font: 13px/1.55 var(--font-body);
  color: var(--ink-2);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  resize: vertical;
}

/* Essai seulement : deux sessions côte à côte. */
.crm-duo-body { margin: 0; background: var(--page); }
.crm-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; height: 100vh; padding: 6px; box-sizing: border-box; }
.crm-duo iframe { width: 100%; height: 100%; border: 1px solid var(--border); background: var(--surface); }

/* Page de connexion, essai seulement : un bouton par personne. */
.login-wrap { flex-direction: column; gap: 14px; padding: 24px 16px; }
.crm-quick { padding: 20px 32px 24px; max-width: 100%; }
.crm-quick h2 { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); }
.login-card { max-width: 100%; }
.crm-quick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.crm-quick-account { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px; }
.crm-quick-account span { color: var(--muted); font-size: 12px; font-weight: 400; }

/* Un filtre qui s'allume : « Pour vous » dans la banque. */
.btn-sm.crm-toggle[aria-pressed="true"] {
  color: var(--accent-strong);
  background: var(--accent-wash);
  border-color: var(--accent);
}
.badge.crm-for-me {
  margin-top: 3px;
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--surface);
}

.card-head h2.crm-late { color: var(--danger); }

/* Fiche : les détails à gauche, l'appel et l'historique à droite (Pipedrive).
 * Au téléphone, l'appel vient en premier. */
.crm-sheet {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-areas: "side main";
  gap: 20px;
  align-items: start;
}
.crm-sheet-main { grid-area: main; min-width: 0; }
.crm-sheet-side { grid-area: side; min-width: 0; }
.crm-details { grid-template-columns: 1fr; }

/* Fiche : « Pas intéressé? » sous l'appel, discret. */
.crm-refusals {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--grid);
  font-size: 13px;
}

/* Ressources : une question par ligne, la réponse s'ouvre dessous. */
.crm-resource-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 18px; }
.crm-search { flex: 1 1 320px; max-width: 460px; }
.crm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-chip {
  font: 500 13.5px/1.2 var(--font-body);
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 11px;
  cursor: pointer;
  transition: color var(--base) var(--ease-fluid), border-color var(--base) var(--ease-fluid),
    background-color var(--base) var(--ease-fluid);
}
.crm-chip.active { color: var(--accent-deep); background: var(--accent-wash); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .crm-chip:hover { border-color: var(--accent-strong); color: var(--ink); }
}
.crm-resource-group { margin: 0 0 22px; }
.crm-resource-group > h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.crm-resource {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  margin: 0 0 8px;
}
.crm-resource > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  font: 600 15.5px/1.35 var(--font-display);
  letter-spacing: -0.01em;
  list-style: none;
  text-wrap: pretty;
  cursor: pointer;
}
.crm-resource > summary::-webkit-details-marker { display: none; }
.crm-resource > summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--base) var(--ease-fluid);
}
.crm-resource[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.crm-resource-body, .crm-resource-links, .crm-resource > .form-actions { padding: 0 16px; }
.crm-resource-body { max-width: 68ch; color: var(--ink-2); }
.crm-resource-body .crm-rich-line { margin: 0 0 10px; line-height: 1.6; }
.crm-resource-body ul { margin: 0 0 10px; padding-left: 20px; }
.crm-resource-body li { margin: 0 0 4px; line-height: 1.55; }
.crm-resource-body li .crm-rich-line { margin: 0; }
.crm-resource-links { font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--grid); padding-top: 10px; }
.crm-resource > :last-child { padding-bottom: 16px; }
.crm-resource > .form-actions { margin-top: 4px; }
tr.crm-row-error td { color: var(--danger); }

/* Équipe : le lien d'accès à copier. */
.crm-link-box { margin-top: 14px; padding: 14px; background: var(--accent-wash); border-radius: var(--radius); }
.crm-link-box label { display: flex; flex-direction: column; gap: 6px; }
.crm-link-box label > span { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.crm-link-box .crm-section-hint { margin: 8px 0 0; color: var(--ink-2); }

/* Téléphone : après toutes les règles générales qu'il remplace. */
@media (max-width: 760px) {
  .crm-phone-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
  .crm-clip.crm-name-link { max-width: 190px; }
  .crm-submit { width: 100%; padding: 11px; font-size: 14px; }
  .crm-choice { padding: 11px 10px; }
  a.crm-call-big { display: block; text-align: center; padding: 11px; font-size: 14px; }
  /* au pouce : des cibles d'au moins 40 px */
  a.crm-call { padding: 10px 16px; font-size: 14px; }
  .crm-row { padding: 12px 0; }
  .subnav a { padding: 10px 12px; }
  .filter-row select, .filter-row input { min-height: 40px; }
  .btn-sm { min-height: 40px; padding-left: 14px; padding-right: 14px; }
  .form-grid input, .form-grid select, .crm-inline-form input, .crm-inline-form select {
    min-height: 40px;
  }
  .crm-table td { padding-top: 12px; padding-bottom: 12px; }
  .crm-col-wide { display: none; }
  /* La fiche au téléphone, dans l'ordre du vendeur : joindre, pourquoi, dossier,
     noter l'appel, historique, détails. */
  .crm-sheet { display: flex; flex-direction: column; gap: 0; }
  .crm-sheet-main, .crm-sheet-side { display: contents; }
  #call-card { order: 1; }
  #signal-card { order: 2; }
  #dossier-card { order: 3; }
  #note-card { order: 4; }
  #history-card { order: 5; }
  #details-card { order: 6; }
  #admin-card { order: 7; }
  .crm-call-actions a { flex: 1 1 0; text-align: center; }
  .crm-radio, .crm-check-line { min-height: 40px; }
  .page-head .crm-head-actions { margin-left: 0; }
}
.crm-today { color: var(--accent-strong); font-weight: 600; }
.crm-kpis { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
button.kpi { font: inherit; text-align: left; cursor: pointer; }
