/* CRM Globalnest — MÊME identité que l'espace client (app.globalnest.eu) :
   titres Lora (serif), UI Plus Jakarta Sans, palette gris-ardoise froide,
   barre latérale blanche, coins nets — RIEN de beige.
   DISTINCTION : l'app est BLEUE, le CRM est CRAMOISI (accent + bandeau
   « CRM · Interne ») pour reconnaître l'outil interne d'un coup d'œil. */

:root {
  /* palette neutre identique à l'app */
  --ink: #0f172a;
  --heading: #1e293b;
  --body: #475569;
  --muted: #64748b;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e5e7eb;
  --gold: #d4a850;         /* étiquettes dorées, comme l'app */
  --gold-soft: #faf5e9;

  /* accent CRM = violet (l'app = bleu) — signature « interne » */
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --accent-soft: #f5f3ff;

  /* couleurs de statut (sémantiques, inchangées) */
  --nouveau: #2563eb;
  --contacte: #d97706;
  --offre_envoyee: #7c3aed;
  --paye: #16a34a;
  --perdu: #6b7280;
  --danger: #c0392b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--body); font-size: 15px; line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2 {
  font-family: "Lora", Georgia, serif; font-weight: 500; color: var(--heading);
  letter-spacing: .01em;
}
h1 { font-size: 24px; margin: 6px 0 18px; }
h2 { font-size: 18px; margin: 24px 0 10px; }

/* ---- disposition : colonne de gauche + contenu (identique à l'app) ---- */
.layout { display: flex; min-height: 100vh; }
#sidebar {
  flex: 0 0 236px; background: #fff; border-right: 1px solid var(--line);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  font-family: "Lora", Georgia, serif; font-weight: 600; font-size: 20px;
  color: var(--heading); display: flex; align-items: center; gap: 10px;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 38px; height: auto; flex: 0 0 auto; }
.brand-suffix {
  display: block; color: var(--accent); font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 1.8px;
}
.env-badge {
  align-self: flex-start; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 3px; margin-top: -8px;
}

.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a {
  color: var(--heading); padding: 9px 11px; border-radius: 3px; font-size: 14px;
  display: flex; align-items: center; gap: 6px;
}
.side-links a:hover { background: var(--accent-soft); text-decoration: none; }
.side-links a.active { background: var(--accent); color: #fff; font-weight: 600; }

.side-footer {
  margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px;
  color: var(--muted); font-size: 12px; display: flex; flex-direction: column; gap: 8px;
  overflow-wrap: anywhere;
}
#lang-select { font-size: 12px; padding: 5px 6px; }
#user-email { color: var(--muted); }
.badge {
  background: var(--danger); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 7px; vertical-align: 1px;
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  #sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; flex: none;
    border-right: none; border-bottom: 2px solid var(--accent);
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 12px;
  }
  .env-badge { margin-top: 0; }
  .side-links {
    flex: 1 1 100%; order: 3; flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .side-links::-webkit-scrollbar { display: none; }
  .side-links a { white-space: nowrap; }
  .side-footer {
    margin-top: 0; border-top: none; padding-top: 0;
    flex-direction: row; align-items: center; margin-left: auto; gap: 10px;
  }
  #user-email { display: none; }
}

main { flex: 1 1 auto; min-width: 0; max-width: 1500px; padding: 24px 32px 60px; }
@media (max-width: 860px) { main { padding: 16px 14px 60px; } }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 4px;
  padding: 18px 20px; margin-bottom: 14px;
}

/* ---- champs & boutons (style app) ---- */
input, select, textarea, button {
  font: inherit; border: 1px solid var(--line); border-radius: 3px;
  padding: 9px 11px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
button { cursor: pointer; }
button.primary {
  background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700;
  padding: 10px 20px; text-transform: uppercase; letter-spacing: .6px; font-size: 13px;
}
button.primary:hover { background: var(--accent-strong); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: #e5c5bf; background: transparent; }
button.danger:hover { background: #fbeeec; }
button:disabled { opacity: .5; cursor: default; }

/* ---- tableau de bord ---- */
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  flex: 1 1 100px; min-width: 100px; background: var(--card); border: 1px solid var(--line);
  border-radius: 4px; padding: 12px 14px; cursor: pointer;
}
.stat b { display: block; font-size: 24px; }
.stat small { color: var(--muted); }
.stat.s-nouveau b { color: var(--nouveau); }
.stat.s-contacte b { color: var(--contacte); }
.stat.s-offre_envoyee b { color: var(--offre_envoyee); }
.stat.s-paye b { color: var(--paye); }
.stat.s-perdu b { color: var(--perdu); }

.reminder-item, .lead-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}
.reminder-item:last-child, .lead-row:last-child { border-bottom: none; }
.reminder-item.late { color: var(--danger); }
.lead-row .who { flex: 1 1 auto; min-width: 0; }
.lead-row .who a { color: var(--heading); font-weight: 600; }
.lead-row .who small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* composeur d'offre */
.offer-grid { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .offer-grid { grid-template-columns: 1fr; } }
.offer-form label { display: block; margin: 8px 0 4px; font-size: 14px; }
.offer-form .frow label { display: flex; align-items: center; gap: 6px; margin: 0; }
.offer-form textarea, .offer-form input[type=text], .offer-form input[type=number] {
  width: 100%; box-sizing: border-box;
}
.offer-form input[type=number] { width: 110px; }
.paylink { font-family: ui-monospace, monospace; font-size: 11px; word-break: break-all; color: var(--muted); }
.offer-preview iframe { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
button.wa { background: #25D366; color: #fff; border: none; }
button.wa:hover { background: #1ebe5b; }

/* badges CA / budget */
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.chip {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 3px;
  background: #f1f5f9; color: var(--muted); white-space: nowrap;
}
.chip.warm { background: var(--gold-soft); color: #8a5f10; font-weight: 600; }
.chip.hot { background: #e3f4e6; color: #187a2f; font-weight: 700; }
.kcard .chips { margin-top: 4px; }

/* ---- statuts ---- */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap;
}
.pill.nouveau { background: var(--nouveau); }
.pill.contacte { background: var(--contacte); }
.pill.offre_envoyee { background: var(--offre_envoyee); }
.pill.paye { background: var(--paye); }
.pill.perdu { background: var(--perdu); }

/* ---- articles (guides SEO) ---- */
.pill.brouillon { background: var(--gold); }
.pill.publie { background: var(--paye); }
.art-form label { display: block; margin: 10px 0 4px; font-size: 14px; }
.art-form .frow label { flex: 0 1 auto; margin: 0; }
.art-form input[type=text], .art-form textarea { width: 100%; box-sizing: border-box; }
.art-form .frow select { min-width: 170px; }

/* ---- kanban ---- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kcol {
  flex: 0 0 230px; background: #eef2f7; border-radius: 4px; padding: 10px;
  min-height: 220px;
}
.kcol h3 { margin: 2px 4px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kcol.dragover { outline: 2px dashed var(--accent); }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  padding: 9px 11px; margin-bottom: 8px; cursor: grab; font-size: 13px;
}
.kcard b { display: block; font-size: 14px; color: var(--heading); }
.kcard small { color: var(--muted); }

/* ---- liste ---- */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.searchbar input[type=search] { flex: 1 1 200px; }
.tl-del {
  flex: 0 0 auto; align-self: flex-start; border: none; background: transparent;
  color: #cbd5e1; font-size: 13px; padding: 2px 6px; border-radius: 4px; line-height: 1;
}
.tl-del:hover { color: var(--danger); background: #fbeeec; }

/* ---- tableau des leads ---- */
.table-wrap { overflow-x: auto; padding: 6px 10px; }
.lead-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lead-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.lead-table th:hover { color: var(--heading); }
.lead-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lead-table tbody tr { cursor: pointer; }
.lead-table tbody tr:hover { background: var(--accent-soft); }
.lead-table tr:last-child td { border-bottom: none; }
.nowrap { white-space: nowrap; }

/* ---- fiche lead ---- */
.lead-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.lead-head h1 { margin: 0; }
.lead-head .contact { color: var(--muted); font-size: 14px; }
.lead-head .contact a { color: var(--accent); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.panel { display: none; margin-top: 10px; }
.panel.open { display: block; }
.outcomes { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.outcomes button.sel { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.frow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }

.answers dt { font-size: 12px; color: var(--muted); margin-top: 8px; }
.answers dd { margin: 0; font-weight: 600; color: var(--heading); }

/* ---- timeline ---- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl li:last-child { border-bottom: none; }
.tl .ico { flex: 0 0 26px; text-align: center; font-size: 17px; }
.tl .when { color: var(--muted); font-size: 12px; }
.tl .body { white-space: pre-wrap; font-size: 14px; margin-top: 2px; }
.tl .twrap { min-width: 0; flex: 1; }

/* ---- écran de connexion ---- */
body.login-mode .layout { display: block; }
.login-wrap { max-width: 400px; margin: 8vh auto 0; padding: 0 20px; text-align: center; }
.login-logo { width: 64px; height: auto; margin-bottom: 14px; }
.login-wrap h1 { margin: 0 0 20px; }
.login-wrap .card { text-align: left; padding: 24px 22px; }
.login-wrap label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.login-wrap input[type=email] { width: 100%; box-sizing: border-box; }
.login-wrap .primary { width: 100%; }
.login-foot { margin-top: 18px; }
.sec-key {
  font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: 2px;
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 4px;
  padding: 12px 14px; margin: 8px 0 12px; text-align: center; word-break: break-all; user-select: all;
}
.login-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-oauth {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; box-sizing: border-box; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 3px; background: #fff; color: var(--heading); font-weight: 600; font-size: 14px;
}
.btn-oauth:hover { background: #f8fafc; text-decoration: none; }
.btn-google .g-ico {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; color: #4285F4; font-weight: 800; font-family: Arial, sans-serif;
  border: 1px solid #e5e7eb;
}
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; padding: 0; text-align: left; }
.linklike:hover { text-decoration: underline; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--heading); color: #fff; padding: 11px 20px; border-radius: 4px;
  font-size: 14px; z-index: 50; max-width: 90vw;
}
#toast.err { background: var(--danger); }

@media (max-width: 640px) {
  h1 { font-size: 20px; }
  .kcol { flex-basis: 200px; }
  /* tableau des leads : on ne garde que Nom, CA et Statut */
  .lead-table th:nth-child(2), .lead-table td:nth-child(2),
  .lead-table th:nth-child(4), .lead-table td:nth-child(4),
  .lead-table th:nth-child(5), .lead-table td:nth-child(5) { display: none; }
  .lead-table td, .lead-table th { padding: 8px 6px; }
  /* fiche lead : boutons d'action en 2 colonnes */
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .actions button { padding: 10px 6px; }
  .offer-preview iframe { height: 55vh; }
  .stat { flex-basis: 44%; min-width: 90px; padding: 10px; }
  .stat b { font-size: 20px; }
}
