/* Interface de l'application : même identité que le CV (theme.css) */
:root {
  --fond: #f4f8f8;
  --carte: #ffffff;
  --filet: #d5dde2;
  --alerte: #a8432b;
  --alerte-fond: #fbeae5;
  --ok: #1b7f7e;
  --todo: #fff3c4;
  --todo-texte: #7a5a00;
  --rayon: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--fond); color: var(--encre); font-family: var(--font-text); font-size: 15px; line-height: 1.5; }
a { color: var(--lagon); }
h1, h2, h3 { font-family: var(--font-display); color: var(--abysse); line-height: 1.15; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lagon); outline-offset: 2px; }

/* ----- Barre du haut ----- */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--abysse); color: #fff; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: #fff; text-decoration: none; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #c9d6de; text-decoration: none; padding: 6px 10px; border-radius: var(--rayon); }
.topbar nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: #fff; }
.mode { margin-left: auto; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.mode.test { background: #a8dadc; color: var(--abysse); }
.mode.reel { background: var(--alerte); color: #fff; }

.view { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.lead { color: var(--brume); margin: 6px 0 0; }
.stack > * + * { margin-top: 20px; }

/* ----- Cartes et chiffres ----- */
.card { background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 18px 20px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi dt { color: var(--brume); font-size: 13px; }
.kpi dd { margin: 2px 0 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--abysse); font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.list { list-style: none; margin: 10px 0 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--filet); }
.list li:first-child { border-top: 0; }
.muted { color: var(--brume); }
.empty { color: var(--brume); padding: 8px 0; }

/* ----- Filtres, tableau, carte ----- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters label { display: grid; gap: 2px; font-size: 13px; color: var(--brume); }
select, input[type="search"], input[type="text"] { border: 1px solid var(--filet); border-radius: var(--rayon); background: #fff; padding: 7px 9px; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
#map { height: 640px; border-radius: var(--rayon); border: 1px solid var(--filet); position: sticky; top: 76px; }
table { width: 100%; border-collapse: collapse; background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); overflow: hidden; }
th, td { text-align: left; padding: 9px 10px; border-top: 1px solid var(--filet); vertical-align: top; }
th { background: #eef6f6; font-size: 13px; color: var(--abysse); border-top: 0; cursor: pointer; user-select: none; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7fbfb; }
td .nom { font-weight: 600; color: var(--abysse); }
.prio { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700; background: #eef6f6; color: var(--abysse); }
.prio.p1 { background: var(--lagon); color: #fff; }

/* Pastilles de statut */
.statut { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; white-space: nowrap; background: #eef1f3; }
.statut[data-s="envoyé"] { background: #dcefee; }
.statut[data-s="relancé"] { background: #e6e1f5; }
.statut[data-s="réponse positive"], .statut[data-s="entretien"] { background: #d5f0dc; }
.statut[data-s="refus"] { background: var(--alerte-fond); }

/* ----- Fiche structure ----- */
.fiche-head { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 16px; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; }
.facts { margin: 0; padding: 0; list-style: none; }
.facts li + li { margin-top: 10px; }
.facts .src { font-size: 13px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--brume); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.warn { background: var(--alerte-fond); color: var(--alerte); border-radius: var(--rayon); padding: 10px 12px; }
.proof { border-left: 3px solid var(--ok); padding: 4px 0 4px 12px; }

/* ----- Éditeur de brouillon ----- */
.editor label { display: grid; gap: 4px; font-weight: 600; color: var(--abysse); font-size: 14px; }
.editor textarea, .editor input { width: 100%; border: 1px solid var(--filet); border-radius: var(--rayon); padding: 9px 11px; background: #fff; font-weight: 400; color: var(--encre); line-height: 1.5; }
.editor textarea { resize: vertical; min-height: 70px; }
.editor .has-todo { border-color: #d9b44a; background: #fffbea; }
.editor .row { display: grid; gap: 14px; }
.badge-todo { display: inline-block; background: var(--todo); color: var(--todo-texte); border-radius: 999px; padding: 1px 9px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { border: 1px solid var(--lagon); background: #fff; color: var(--lagon); border-radius: var(--rayon); padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: #eef6f6; }
.btn.primary { background: var(--lagon); color: #fff; }
.btn.primary:hover { background: #166a69; }
.btn.danger { border-color: var(--alerte); background: var(--alerte); color: #fff; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.hint { font-size: 13px; color: var(--brume); }

/* ----- Boîte de dialogue d'envoi ----- */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(19, 41, 61, 0.3); }
dialog::backdrop { background: rgba(19, 41, 61, 0.45); }
.dlg { padding: 22px 24px; }
.dlg .actions { margin-top: 18px; justify-content: flex-end; }
.steps { margin: 0; padding-left: 20px; }
.steps > li + li { margin-top: 12px; }
.steps .btn { display: inline-block; margin-top: 6px; text-decoration: none; }
.recipient { font-size: 18px; font-weight: 700; color: var(--abysse); overflow-wrap: anywhere; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--abysse); color: #fff; padding: 10px 16px; border-radius: var(--rayon); opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; }
.toast.err { background: var(--alerte); }

@media (max-width: 900px) {
  .split, .grid-2 { grid-template-columns: 1fr; }
  #map { position: static; height: 360px; }
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar nav a { white-space: nowrap; }
  .mode { font-size: 12px; }
  .view { padding: 20px 16px 48px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ----- v2 : éléments ajoutés ----- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--carte); border: 1px solid var(--filet); }
.chip.ok { color: var(--ok); border-color: #b9d9d8; }
.chip.off { color: var(--brume); }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; margin-left: 6px; border-radius: 999px; background: #eef6f6; color: var(--abysse); font-family: var(--font-text); font-size: 13px; vertical-align: middle; }
.items { list-style: none; margin: 10px 0 0; padding: 0; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 0; border-top: 1px solid var(--filet); }
.item:first-child { border-top: 0; }
.item .nom { font-weight: 600; color: var(--abysse); text-decoration: none; }
.item .nom:hover { text-decoration: underline; }
.item .right { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; text-align: right; }
.item.reply { align-items: flex-start; }
.extrait { margin: 6px 0 0; white-space: pre-line; color: var(--encre); max-height: 9em; overflow: auto; }
h3 { margin-top: 14px; color: var(--brume); font-family: var(--font-text); font-weight: 600; font-size: 13px; }
.badge-ok { display: inline-block; background: #d5f0dc; color: #1d5b33; border-radius: 999px; padding: 1px 9px; font-size: 13px; }
.classe { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; background: #eef1f3; }
.classe[data-c="positive"], .classe[data-c="entretien"] { background: #d5f0dc; color: #1d5b33; }
.classe[data-c="négative"] { background: var(--alerte-fond); color: var(--alerte); }
.classe[data-c="question"] { background: var(--todo); color: var(--todo-texte); }
.btn.small { padding: 4px 10px; font-size: 13.5px; text-decoration: none; display: inline-block; }
.actions.end { justify-content: flex-end; }
.full { width: 100%; margin-top: 10px; border: 1px solid var(--filet); border-radius: var(--rayon); padding: 9px 11px; }
.ok { color: var(--ok); }
.ko { color: var(--alerte); }

/* Étapes de la candidature */
.steps-bar { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; counter-reset: step; flex-wrap: wrap; }
.steps-bar li { counter-increment: step; flex: 1 1 110px; padding: 8px 10px; border-radius: var(--rayon); background: var(--carte); border: 1px solid var(--filet); color: var(--brume); font-size: 14px; }
.steps-bar li::before { content: counter(step) ". "; font-weight: 700; }
.steps-bar li.done { background: #eef6f6; border-color: #b9d9d8; color: var(--abysse); }
.steps-bar li.done::before { content: "✓ "; color: var(--ok); }
.steps-bar li.current { border-color: var(--lagon); color: var(--abysse); font-weight: 600; }

/* Barre d'envoi collée en bas de l'éditeur */
.sendbar { position: sticky; bottom: 0; background: var(--carte); border-top: 1px solid var(--filet); padding: 12px 0 2px; display: grid; gap: 10px; }

/* Statistiques : barres horizontales, une seule teinte (une seule mesure par barre) */
table.bars { border: 0; background: transparent; }
table.bars th { background: transparent; cursor: default; padding-left: 0; }
table.bars td { padding: 7px 10px 7px 0; vertical-align: middle; }
table.bars td.num, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { display: inline-block; vertical-align: middle; width: 120px; height: 10px; border-radius: 4px; background: #e6eef0; overflow: hidden; margin-right: 8px; }
.bar span { display: block; height: 100%; background: var(--lagon); border-radius: 0 4px 4px 0; }
tr.faible { opacity: 0.55; }
.recos { margin: 10px 0 0; padding-left: 20px; }
.recos li + li { margin-top: 6px; }

/* Page de connexion */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(380px, 100%); display: grid; gap: 14px; }
.login label { display: grid; gap: 4px; font-weight: 600; color: var(--abysse); font-size: 14px; }
.login input { border: 1px solid var(--filet); border-radius: var(--rayon); padding: 9px 11px; font-weight: 400; }
