/* Espaces connectés (admin, téléconseiller, client) : complète style.css */
body.app { background: var(--soft); min-height: 100vh; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.app-side {
  background: var(--blue-deep); color: #fff; padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 2rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.app-side .brand { color: #fff; padding: 0 .5rem; }
.app-side .brand { flex-direction: column; align-items: flex-start; gap: .5rem; }
.app-side .brand-logo { height: auto; width: 100%; max-width: 210px; }
.app-side .brand-role { color: var(--ochre); font-weight: 700; font-size: .82rem; padding-left: .2rem; }
.app-nav { display: grid; gap: .25rem; }
.app-nav a {
  display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: var(--r-sm);
  color: rgba(255,255,255,.8); text-decoration: none; font-weight: 600;
}
.app-nav a svg { width: 20px; height: 20px; flex: none; }
.app-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-nav a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 var(--ochre); }
.nav-count { margin-left: auto; background: var(--ochre); color: var(--ink); border-radius: 999px; font-size: .75rem; font-weight: 800; padding: .05rem .55rem; }
.app-side-foot { margin-top: auto; display: grid; gap: .4rem; padding: 0 .5rem; font-size: .9rem; }
.app-side-foot a { color: rgba(255,255,255,.7); text-decoration: none; }
.app-side-foot a:hover, .app-side-foot a[aria-current="page"] { color: #fff; text-decoration: underline; }

.app-top {
  display: flex; align-items: center; justify-content: flex-end; gap: 1rem; padding: .9rem 2rem;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.app-user { display: flex; align-items: center; gap: 1rem; }
.app-user > span { display: flex; flex-direction: column; text-align: right; line-height: 1.25; }
.app-user small { color: var(--muted); }
.app-user .btn { font-size: .88rem; }
.side-toggle { display: none; margin-right: auto; background: none; border: 0; padding: .4rem; cursor: pointer; }
.side-toggle span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 5px 0; border-radius: 2px; }

.app-content { padding: 2rem; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.page-head h1 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); margin: 0; }
.page-head p { margin: .3rem 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: .75rem; color: var(--blue); font-weight: 700; text-decoration: none; }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.kpi { background: #fff; border-radius: var(--r); padding: 1.25rem 1.4rem; border: 1px solid var(--line); }
.kpi strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: 2rem; line-height: 1.1; color: var(--blue); font-variant-numeric: lining-nums tabular-nums; }
.kpi span { color: var(--muted); font-size: .92rem; }
.kpi.is-alert { border-color: var(--ochre); background: var(--ochre-soft); }
.kpi a { color: inherit; text-decoration: none; display: block; }
.kpi a:hover span { text-decoration: underline; }

/* Panneaux et grilles */
.panel { background: #fff; border-radius: var(--r); border: 1px solid var(--line); padding: 1.5rem; margin-bottom: 1.5rem; }
.panel > h2, .panel-head h2 { font-size: 1.25rem; margin: 0 0 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.panel-head a { color: var(--blue); font-weight: 700; font-size: .92rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.grid-2 > .panel { margin-bottom: 0; }
.stack { display: grid; gap: 1.5rem; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
.data th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 700; padding: .65rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data td { padding: .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tr:last-child td { border-bottom: 0; }
.data a { color: var(--blue); font-weight: 700; text-decoration: none; }
.data a:hover { text-decoration: underline; }
.data small { color: var(--muted); display: block; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); padding: 1.5rem; text-align: center; background: var(--soft); border-radius: var(--r-sm); }

/* Statuts */
.st { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 800; white-space: nowrap; background: var(--soft); color: var(--muted); }
.st-active, .st-confirme, .st-rdv { background: var(--sky); color: var(--blue); }
.st-honore { background: #E7F4EC; color: #1D5A35; }
.st-a-verifier, .st-rappel, .st-nouveau, .st-brouillon { background: var(--ochre-soft); color: #7A4E0B; }
.st-refuse, .st-non-honore, .st-annule, .st-pas-interesse { background: #FCE8E6; color: var(--danger); }
.st-pause, .st-terminee, .st-injoignable, .st-hors-cible { background: #EFEBE6; color: var(--muted); }

/* Progression */
.progress { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.progress-label { display: flex; justify-content: space-between; font-size: .88rem; color: var(--muted); margin-bottom: .35rem; }
.funnel { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-top: 1rem; }
.funnel div { background: var(--soft); border-radius: var(--r-sm); padding: .8rem; }
.funnel strong { display: block; font-size: 1.4rem; font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.funnel span { font-size: .82rem; color: var(--muted); }

/* Filtres */
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.toolbar input[type="search"], .toolbar select {
  font: inherit; padding: .6rem .9rem; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; color: var(--ink);
}
.toolbar input[type="search"] { flex: 1 1 240px; }
.toolbar a { color: var(--blue); font-weight: 700; }

/* Formulaires dans les espaces */
.app .form-grid { margin-bottom: 1.25rem; }
.app .form textarea { min-height: 110px; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { font: inherit; padding: .45rem .7rem; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.btn-xs { padding: .35rem .8rem; font-size: .85rem; }
.help { color: var(--muted); font-size: .88rem; margin: .25rem 0 0; font-weight: 400; }
.checkbox-list { display: grid; gap: .4rem; }
.checkbox-list label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--ochre-soft); padding: .1rem .5rem; border-radius: 6px; user-select: all; }

/* Poste d'appel */
.call-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.5rem; align-items: start; }
.prospect-card h2 { font-size: 1.6rem; margin-bottom: .25rem; }
.prospect-card .who { color: var(--muted); margin: 0 0 1rem; }
.call-number {
  display: inline-flex; align-items: center; gap: .6rem; font-size: 1.5rem; font-weight: 800; color: var(--blue);
  text-decoration: none; background: var(--sky); padding: .6rem 1.1rem; border-radius: 999px; margin-bottom: 1rem;
}
.call-number svg { width: 24px; height: 24px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.script { white-space: pre-line; background: var(--soft); border-radius: var(--r-sm); padding: 1rem 1.2rem; font-size: .95rem; max-height: 340px; overflow-y: auto; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; font-size: .92rem; }
.history li { border-left: 3px solid var(--line); padding-left: .8rem; }
.history small { color: var(--muted); }
.result-options { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.fiche { background: var(--sky); border-radius: var(--r); padding: 1.25rem; margin-bottom: 1.25rem; }
.fiche h3 { margin-top: 0; font-size: 1.1rem; }

/* Page de connexion */
body.auth-page { background: #fff; }
.auth-layout { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-visual { position: relative; background: var(--blue-deep); color: #fff; display: flex; align-items: flex-end; overflow: hidden; }
.auth-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.auth-visual p { position: relative; font-family: var(--font-display); font-size: 1.7rem; line-height: 1.25; padding: 3rem; max-width: 26ch; margin: 0; }
.auth-box { padding: 3rem clamp(1.5rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: center; max-width: 560px; }
.auth-box .brand { margin-bottom: 2.5rem; }
.auth-box h1 { font-size: 2rem; margin-bottom: .3rem; }
.auth-form { display: grid; gap: 1rem; margin: 1.5rem 0; }
.auth-form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 700; font-size: .95rem; }

/* Responsive */
@media (max-width: 860px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 1000px) {
  .grid-2, .call-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .app-side.is-open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .side-toggle { display: block; }
  .app-top { padding: .75rem 16px; }
  .app-content { padding: 1.25rem 16px; }
  .funnel { grid-template-columns: repeat(2, 1fr); }
  .app-user > span small { display: none; }
}

/* Statuts des demandes du site */
.st-en-cours { background: var(--sky); color: var(--blue); }
.st-traite { background: #E7F4EC; color: #1D5A35; }

/* Statuts des e-mails */
.st-envoye { background: #E7F4EC; color: #1D5A35; }
.st-echec { background: #FCE8E6; color: var(--danger); }
.st-simule { background: var(--ochre-soft); color: #7A4E0B; }

/* Notifications */
.app-top { gap: 1rem; }
.bell { position: relative; }
.bell-btn { position: relative; background: none; border: 0; padding: .45rem; border-radius: 50%; cursor: pointer; color: var(--ink); display: grid; place-items: center; }
.bell-btn:hover { background: var(--soft); }
.bell-btn svg { width: 24px; height: 24px; }
.bell-count { position: absolute; top: 0; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
.bell-panel { position: absolute; right: 0; top: calc(100% + .5rem); width: min(360px, 90vw); background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); z-index: 30; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.link-btn { background: none; border: 0; color: var(--blue); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; padding: 0; }
.bell-list { list-style: none; margin: 0; padding: .25rem 0; max-height: 360px; overflow-y: auto; }
.bell-list li { padding: .65rem 1rem; display: flex; flex-direction: column; gap: .1rem; font-size: .92rem; border-bottom: 1px solid var(--soft); }
.bell-list li:last-child { border-bottom: 0; }
.bell-list li.is-unread { background: var(--sky); }
.bell-list a { color: var(--ink); text-decoration: none; font-weight: 600; }
.bell-list a:hover { color: var(--blue); text-decoration: underline; }
.bell-list small { color: var(--muted); font-size: .78rem; }

/* Valeur mise à jour en direct */
@keyframes live-flash { from { background: var(--ochre-soft); } to { background: transparent; } }
.is-updated { animation: live-flash 1.6s ease-out; border-radius: 6px; }

/* IA */
.ai-box { background: var(--sky); border-radius: var(--r); padding: 1.25rem; margin-bottom: 1.5rem; display: grid; gap: .75rem; }
.ai-box .form-grid { margin-bottom: 0; }
.ai-box .btn { justify-self: start; }
.ai-status { display: block; font-size: .9rem; color: var(--blue); font-weight: 600; }
.ai-status:empty { display: none; }
.ai-status.is-error { color: var(--danger); }
.ai-panel { border-color: var(--sky-mid); }
.ai-label { display: flex; flex-direction: column; gap: .35rem; font-weight: 700; font-size: .95rem; margin-bottom: .75rem; }
.ai-label textarea { font: inherit; font-weight: 400; padding: .7rem .9rem; border: 1.5px solid var(--line); border-radius: var(--r-sm); }
.ai-answer { margin-top: 1rem; background: var(--sky); border-radius: var(--r-sm); padding: 1rem 1.2rem; }
.ai-answer p { margin: 0 0 .5rem; }
.ai-answer p:last-child { margin: 0; }

/* Score IA */
.score { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 .4rem; border-radius: 999px; font-weight: 800; font-size: .82rem; }
.score-high { background: #E7F4EC; color: #1D5A35; }
.score-mid { background: var(--ochre-soft); color: #7A4E0B; }
.score-low { background: #FCE8E6; color: var(--danger); }
.score-none { background: var(--soft); color: var(--muted); }

/* Rapports */
.report h2 { font-size: 1.4rem; }
.report h3 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
.report ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; }
.quota { display: grid; gap: .35rem; margin-bottom: 1rem; }

/* Statuts du journal d'IA */
.st-ok { background: #E7F4EC; color: #1D5A35; }
.st-erreur, .st-refus { background: #FCE8E6; color: var(--danger); }
.st-quota { background: var(--ochre-soft); color: #7A4E0B; }

/* Formules (Contenus du site) */
.plan-item { border: 1px solid var(--line); border-radius: var(--r-sm); padding: .8rem 1rem; margin-bottom: .6rem; }
.plan-item summary { cursor: pointer; }
.plan-item .plan-form { margin-top: 1rem; }

/* Les colonnes de grille ne doivent pas s'élargir à la taille de leurs tableaux (mobile) */
.app-main, .app-content, .grid-2 > *, .call-grid > *, .stack > * { min-width: 0; }
@media (max-width: 860px) {
  .app-top { flex-wrap: wrap; }
  .app-user { gap: .5rem; }
  .app-user .btn { padding: .4rem .7rem; }
}

/* Mobile : en-tête sur une ligne, indicateurs sur deux colonnes */
@media (max-width: 560px) {
  .app-top { flex-wrap: nowrap; }
  .app-user > span { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .kpi { padding: 1rem; }
  .kpi strong { font-size: 1.6rem; }
}

/* Message avec bouton d'action (ex. activer une campagne) */
.alert-action { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.alert-action form { margin: 0; }

/* Relecture des entreprises proposées par l'IA */
.suggestions td { vertical-align: top; }
.suggestions td small { display: block; }
.input-sm { font: inherit; width: 100%; min-width: 150px; padding: .45rem .6rem; border: 1.5px solid var(--line); border-radius: var(--r-sm); }
.input-sm:focus { outline: none; border-color: var(--blue); }

/* Progression d'une tâche d'IA longue */
.progress-panel { display: flex; gap: 1rem; align-items: flex-start; margin-top: 1.25rem; padding: 1.25rem 1.5rem; background: var(--sky); border: 1px solid var(--sky-mid); border-radius: var(--r); }
.progress-panel strong { font-size: 1.05rem; }
.progress-panel p { margin: .35rem 0 0; }
.spinner { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--sky-mid); border-top-color: var(--blue); animation: spin 1s linear infinite; margin-top: .15rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none !important; border-top-color: var(--ochre); } }
.suggestions .st { margin: .2rem 0 .1rem; }
.st-fiab-confirmee { background: #E7F4EC; color: #1D5A35; }
.st-fiab-probable { background: var(--sky); color: var(--blue); }
.st-fiab-douteuse { background: #FCE8E6; color: var(--danger); }
.suggestions .suggestion-alert { margin-top: .4rem; color: #7A4E0B; font-weight: 700; }

/* Prospection écrite : e-mails et WhatsApp */
.kpis-sm { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 1.25rem 0; }
.kpis-sm .kpi { padding: .85rem 1rem; }
.kpis-sm .kpi strong { font-size: 1.5rem; }
.help-label { align-self: end; color: var(--muted); font-size: .88rem; font-weight: 400; }
.email-state svg, .msg-history svg { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: .2rem; }
.wa-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; }
.btn-whatsapp { background: #1F7A4D; color: #fff; }
.btn-whatsapp:hover { background: #17633E; color: #fff; }
.btn-whatsapp svg { width: 18px; height: 18px; }
.msg-history { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .5rem; }
.msg-history li { font-size: .9rem; }
.followup { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.followup summary { cursor: pointer; }
.followup .btn svg { width: 16px; height: 16px; }

/* Performance de l'équipe et objectifs */
.perf-table td small { display: block; color: var(--muted); }
.perf-table .is-bad { color: var(--danger); font-weight: 800; }
.goal-line { display: block; font-size: .85rem; }
.goal-form { margin-top: .5rem; gap: .5rem; align-items: end; }
.goal-form input { width: 5.5rem; }
.goal { margin-bottom: 1rem; }
.goal-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .92rem; margin-bottom: .35rem; }
.goal-done .progress span { background: #2E8B57; }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.ranking li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .75rem; border-radius: 10px; background: var(--soft); }
.ranking li.is-me { background: var(--sky); font-weight: 800; }
.recall-slots { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: -.25rem; }
.best-time { margin-top: .5rem; color: #7A4E0B; font-weight: 700; }

.admin-map iframe { width: 100%; height: 260px; border: 0; border-radius: 12px; margin-top: 1rem; }

/* Candidatures */
.application summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; list-style: none; }
.application summary::-webkit-details-marker { display: none; }
.application[open] summary { margin-bottom: 1rem; }
.application .motivation { margin: 1rem 0; padding: .75rem 1rem; background: var(--soft); border-left: 4px solid var(--ochre); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.application-form { margin-top: 1rem; }
.application .inline-form { margin-top: .5rem; }

/* Note client des rendez-vous (étoiles, de droite à gauche pour l'effet de survol) */
.rating { border: 0; padding: 0; margin: 0 0 1rem; }
.rating legend { font-weight: 700; margin-bottom: .35rem; }
.rating-stars { display: inline-flex; flex-direction: row-reverse; gap: .15rem; }
.rating-stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating-stars label { font-size: 1.9rem; line-height: 1; color: var(--line); cursor: pointer; transition: color .1s; }
.rating-stars label:hover, .rating-stars label:hover ~ label, .rating-stars input:checked ~ label { color: var(--ochre); }
.rating-stars input:focus-visible + label { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.stars { color: var(--ochre); font-size: 1.2rem; letter-spacing: .1em; }

/* Télévente */
.st-vendu, .st-confirmee, .st-vente { background: var(--sky); color: var(--blue); }
.st-livree { background: #E7F4EC; color: #1D5A35; }
.st-refusee { background: #FCE8E6; color: var(--danger); }
.st-annulee { background: #EFEBE6; color: var(--muted); }
.catalogue { list-style: none; padding: 0; margin: .5rem 0 1.25rem; display: grid; gap: .35rem; font-size: .93rem; }
.catalogue li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .7rem; background: var(--soft); border-radius: var(--r-sm); }
.catalogue strong { white-space: nowrap; color: var(--blue); }
.order-total { font-family: var(--font-display); font-size: 1.6rem; color: var(--blue); }
