:root {
  --nuit: #13213F;
  --nuit-2: #1D2E52;
  --or: #C8A24A;
  --or-pale: #EADBB0;
  --fond: #F3F5F8;
  --surface: #FFFFFF;
  --encre: #18202E;
  --gris: #5F6B7E;
  --trait: #DDE2EA;
  --signal: #D9483B;
  --vert: #2E8F66;
  --bleu: #3765C9;
  --rayon: 14px;
  --display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --texte: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--texte); color: var(--encre); background: var(--fond); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--bleu); }
:focus-visible { outline: 2px solid var(--or); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 1.35rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }
.muted { color: var(--gris); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- structure ---------- */
.app { min-height: 100vh; padding-bottom: calc(76px + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--nuit); color: #fff; padding: calc(10px + var(--safe-t)) 18px 10px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.1rem; }
.brand svg { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.robot-chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.1); }
.robot-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--vert); }
.robot-chip.paused i { background: var(--signal); }
.robot-chip.test i { background: var(--or); }
.robot-chip.running i { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
main { max-width: 1080px; margin: 0 auto; padding: 18px; }
section + section { margin-top: 28px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--trait); display: flex; padding: 6px 4px calc(6px + var(--safe-b)); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; color: var(--gris); text-decoration: none; padding: 4px 0; position: relative; }
.tabs a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tabs a.active { color: var(--nuit); font-weight: 600; }
.tabs a.active svg { stroke: var(--nuit); }
.badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--signal); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }

@media (min-width: 900px) {
  .app { padding-bottom: 0; padding-left: 220px; }
  .tabs { top: 0; bottom: 0; right: auto; width: 220px; flex-direction: column; border-top: 0; border-right: 1px solid var(--trait); padding: 84px 12px 12px; gap: 4px; }
  .tabs a { flex: none; flex-direction: row; gap: 12px; font-size: .95rem; padding: 10px 12px; border-radius: 10px; }
  .tabs a.active { background: var(--fond); }
  .tabs .badge { position: static; margin-left: auto; }
  .topbar { position: fixed; left: 0; right: 0; z-index: 40; width: 220px; right: auto; height: 64px; background: var(--nuit); }
  .tabs { padding-top: 76px; }
  main { padding-top: 26px; }
}

/* ---------- bandeau d'accueil ---------- */
.hero { background: var(--nuit); color: #fff; margin: -18px -18px 0; padding: 8px 18px 26px; }
@media (min-width: 900px) { .hero { margin: 0; border-radius: var(--rayon); padding: 26px; } }
.hero-top { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.today-num { font-family: var(--display); font-size: 3.2rem; line-height: 1; font-weight: 700; }
.today-num span { color: rgba(255,255,255,.45); font-weight: 500; }
.today-label { color: rgba(255,255,255,.7); font-size: .9rem; margin-top: 4px; }
.progress { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; margin-top: 12px; overflow: hidden; width: 220px; max-width: 100%; }
.progress b { display: block; height: 100%; background: var(--or); border-radius: 3px; }
.cta-validate { display: flex; align-items: center; gap: 12px; text-decoration: none; background: var(--signal); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; }
.cta-validate .n { font-family: var(--display); font-size: 1.6rem; line-height: 1; }

.funnel { margin-top: 26px; display: grid; gap: 7px; }
.funnel-row { display: grid; grid-template-columns: 112px 1fr 58px; align-items: center; gap: 10px; font-size: .88rem; }
.funnel-row .lbl { color: rgba(255,255,255,.78); }
.funnel-row .bar { height: 26px; background: rgba(255,255,255,.07); border-radius: 6px; position: relative; overflow: hidden; }
.funnel-row .bar b { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--or), #E2C77C); border-radius: 6px; transform-origin: left; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
.funnel-row .bar em { position: absolute; left: 10px; top: 0; line-height: 26px; font-style: normal; font-family: var(--display); font-weight: 650; color: var(--nuit); mix-blend-mode: normal; }
.funnel-row .bar em.out { color: #fff; }
.funnel-row .pct { text-align: right; color: var(--or-pale); font-variant-numeric: tabular-nums; }
@keyframes grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .funnel-row .bar b { animation: none; } .robot-chip.running i { animation: none; } }

/* ---------- blocs ---------- */
.panel { background: var(--surface); border-radius: var(--rayon); padding: 18px; border: 1px solid var(--trait); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid-2 { display: grid; gap: 18px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--trait); border-radius: var(--rayon); overflow: hidden; border: 1px solid var(--trait); }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); padding: 14px 16px; }
.kpi b { display: block; font-family: var(--display); font-size: 1.7rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .82rem; color: var(--gris); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-weight: 600; color: var(--gris); font-size: .8rem; padding: 6px 8px; border-bottom: 1px solid var(--trait); }
td { padding: 9px 8px; border-bottom: 1px solid var(--fond); font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; white-space: nowrap; }

.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--gris); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- boutons & champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--trait); background: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--encre); min-height: 44px; }
.btn.primary { background: var(--nuit); border-color: var(--nuit); color: #fff; }
.btn.gold { background: var(--or); border-color: var(--or); color: var(--nuit); }
.btn.danger { color: var(--signal); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; }
label.field small { display: block; color: var(--gris); font-size: .8rem; margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=url], input[type=search], input[type=time], textarea, select {
  width: 100%; border: 1px solid var(--trait); background: var(--surface); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--fond); }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--trait); position: relative; cursor: pointer; flex: none; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked { background: var(--vert); }
.switch input:checked::after { transform: translateX(20px); }
.switch b { display: block; font-weight: 600; }
.switch small { color: var(--gris); font-size: .82rem; }
.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--trait); border-radius: 10px; overflow: hidden; width: max-content; }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--fond); font-size: 1.3rem; cursor: pointer; }
.stepper output { min-width: 56px; text-align: center; font-family: var(--display); font-size: 1.25rem; font-weight: 650; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; }
.days span { display: inline-block; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--trait); cursor: pointer; }
.days input:checked + span { background: var(--nuit); color: #fff; border-color: var(--nuit); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; background: var(--fond); font-size: .82rem; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; color: var(--gris); font-size: 1rem; line-height: 1; }

/* ---------- validations ---------- */
.approval { background: var(--surface); border-radius: var(--rayon); border: 1px solid var(--trait); overflow: hidden; }
.approval + .approval { margin-top: 18px; }
.approval-head { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--fond); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--nuit-2); color: var(--or-pale); display: grid; place-items: center; font-family: var(--display); font-weight: 650; flex: none; }
.approval-head .who { flex: 1; min-width: 0; }
.approval-head .who b { display: block; }
.approval-head .who span { display: block; color: var(--gris); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kind { font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: #FCE9E6; color: var(--signal); white-space: nowrap; }
.kind.invite { background: #E8EEFB; color: var(--bleu); }
.kind.first_message { background: #F6EFD9; color: #8A6A16; }
.thread { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; background: #FAFBFC; max-height: 340px; overflow-y: auto; }
.bubble { max-width: 82%; padding: 9px 13px; border-radius: 18px; white-space: pre-wrap; font-size: .93rem; line-height: 1.42; }
.bubble.in { align-self: flex-start; background: #E9ECF1; border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--nuit); color: #fff; border-bottom-right-radius: 6px; }
.bubble.draft { align-self: flex-end; background: transparent; border: 1.5px dashed var(--or); color: var(--encre); }
.reading { padding: 12px 16px; display: grid; gap: 8px; font-size: .9rem; border-top: 1px solid var(--fond); }
.reading dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.reading dt { color: var(--gris); }
.reading dd { margin: 0; }
.interest { font-weight: 700; }
.interest.fort { color: var(--vert); }
.interest.moyen { color: #A57A12; }
.interest.faible { color: var(--gris); }
.compose { padding: 14px 16px 16px; border-top: 1px solid var(--fond); }
.compose .hint { font-size: .8rem; margin: 6px 0 12px; }
.compose .hint.bad { color: var(--signal); }
.compose .hint.ok { color: var(--vert); }
.empty { text-align: center; padding: 48px 20px; color: var(--gris); }
.empty h3 { color: var(--encre); margin-bottom: 6px; }

/* ---------- prospects ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input { flex: 1 1 200px; }
.filters select { flex: 0 1 220px; }
.plist { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
.prow { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--fond); text-decoration: none; color: inherit; }
.prow:last-child { border-bottom: 0; }
.prow:hover { background: #FAFBFC; }
.prow .who b { display: block; }
.prow .who span { font-size: .84rem; color: var(--gris); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .right { text-align: right; font-size: .8rem; }
.score { font-family: var(--display); font-weight: 650; font-size: 1.05rem; }
.status { display: inline-block; font-size: .74rem; padding: 2px 8px; border-radius: 6px; background: var(--fond); color: var(--gris); margin-top: 3px; white-space: nowrap; }
.status.hot { background: #FCE9E6; color: var(--signal); }
.status.go { background: #E3F2EA; color: var(--vert); }

.scorebars { display: grid; gap: 8px; }
.scorebar { display: grid; grid-template-columns: 150px 1fr 46px; gap: 10px; align-items: center; font-size: .85rem; }
.scorebar .track { height: 8px; background: var(--fond); border-radius: 4px; overflow: hidden; }
.scorebar .track b { display: block; height: 100%; background: var(--or); }
.facts dt { font-size: .8rem; color: var(--gris); margin-top: 10px; }
.facts dd { margin: 2px 0 0; white-space: pre-wrap; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.timeline li { padding: 7px 0 7px 18px; border-left: 2px solid var(--trait); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--or); }

/* ---------- activité ---------- */
.run { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--fond); cursor: pointer; }
.run .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--vert); }
.run .dot.stopped, .run .dot.error { background: var(--signal); }
.run .dot.running { background: var(--or); }
pre.log { background: var(--nuit); color: #DCE3F0; padding: 14px; border-radius: 10px; font-size: .78rem; overflow-x: auto; white-space: pre-wrap; max-height: 60vh; }

.notice { padding: 12px 14px; border-radius: 10px; background: #F6EFD9; color: #6E5410; font-size: .9rem; }
.notice.bad { background: #FCE9E6; color: #9C2B20; }
.notice.good { background: #E3F2EA; color: #1F6A4A; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: var(--nuit); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: .92rem; z-index: 99; box-shadow: 0 8px 30px rgba(19,33,63,.3); max-width: 90vw; }

/* ---------- connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--nuit); padding: 24px; }
.login form { width: 100%; max-width: 360px; color: #fff; }
.login h1 { font-size: 2rem; margin: 18px 0 4px; }
.login p { color: rgba(255,255,255,.65); margin: 0 0 24px; }
.login input { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.2); color: #fff; margin-bottom: 12px; }
.login .btn { width: 100%; }
.login .err { color: #FF9C90; min-height: 1.5em; font-size: .9rem; }
