:root {
  --ink: #16152b;
  --ink-2: #4a4966;
  --ink-3: #8a89a3;
  --line: #e7e6ef;
  --line-2: #f1f0f6;
  --bg: #f7f7fb;
  --card: #ffffff;
  --accent: #5b4bff;
  --accent-2: #ece9ff;
  --accent-ink: #3b2fd1;
  --green: #12a46b;
  --green-2: #e3f6ee;
  --amber: #c98a06;
  --amber-2: #fdf3dc;
  --red: #d93b4b;
  --red-2: #fde9eb;
  --blue: #2477d6;
  --blue-2: #e5f0fc;
  --sf: #0b8bd6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 21, 43, .04), 0 2px 10px rgba(22, 21, 43, .04);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small, .muted { color: var(--ink-3); }
code { background: var(--line-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #c9c8de; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 750; font-size: 17px; padding: 4px 10px 18px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #7b6dff, #5b4bff 55%, #2e22b8); display: grid; place-items: center; }
.nav a { display: flex; align-items: center; gap: 10px; color: #c9c8de; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(123,109,255,.22); color: #fff; }
.nav svg { width: 17px; height: 17px; opacity: .9; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 14px 8px 0; display: flex; gap: 10px; align-items: center; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { font-size: 12px; color: #9c9bb8; }
.side-foot button { background: transparent; border: 0; color: #9c9bb8; cursor: pointer; padding: 6px; border-radius: 6px; }
.side-foot button:hover { color: #fff; background: rgba(255,255,255,.08); }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 22px 32px 0; }
.topbar .spacer { flex: 1; }
.page { padding: 20px 32px 48px; max-width: 1320px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.sub { color: var(--ink-3); margin-top: 3px; }

/* ---------- Composants ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h .spacer { flex: 1; }
.card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1050px) { .g2, .g3, .g-main { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.sf { background: var(--sf); border-color: var(--sf); color: #fff; }
.btn svg { width: 15px; height: 15px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 5px; border-radius: 6px; color: var(--ink-3); }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
label.f > em { display: block; font-style: normal; font-size: 12px; color: var(--ink-3); margin-top: 5px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; color: var(--ink); background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus, .editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
textarea { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.row .grow { flex: 1 1 200px; }
.row .shrink { flex: 1 1 300px; min-width: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin-bottom: 12px; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check b { display: block; font-weight: 600; }
.check small { display: block; }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #d5d4e2; border-radius: 20px; transition: .15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.nodot::before { display: none; }
.pill.green { background: var(--green-2); color: var(--green); }
.pill.amber { background: var(--amber-2); color: var(--amber); }
.pill.red { background: var(--red-2); color: var(--red); }
.pill.blue { background: var(--blue-2); color: var(--blue); }
.pill.violet { background: var(--accent-2); color: var(--accent-ink); }
.pill.sf { background: #e3f3fc; color: var(--sf); }
.tag { display: inline-block; background: var(--accent-2); color: var(--accent-ink); border-radius: 5px; padding: 1px 7px; font-size: 12px; margin: 1px 3px 1px 0; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfbfd; white-space: nowrap; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #fafaff; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty { padding: 42px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; }
.avatars { display: inline-flex; }
.avatars .avatar { border: 2px solid #fff; margin-left: -8px; width: 28px; height: 28px; font-size: 11px; }
.avatars .avatar:first-child { margin-left: 0; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person div { min-width: 0; }
.person b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi { padding: 14px 16px; }
.kpi span { font-size: 12.5px; color: var(--ink-3); font-weight: 550; }
.kpi b { display: block; font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 12px; }
.bar { height: 6px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }

.chart svg { width: 100%; height: 220px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed.scroll { max-height: 520px; overflow: auto; }
.feed li { display: flex; gap: 11px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 13px; }
.feed .txt { flex: 1; min-width: 0; font-size: 13px; line-height: 1.45; }
.feed time { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { color: var(--accent-ink); border-color: var(--accent); }
.tabs .count { background: var(--line-2); border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 4px; color: var(--ink-2); }

/* Séquence */
.seq { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1050px) { .seq { grid-template-columns: 1fr; } }
.steps { display: flex; flex-direction: column; }
.step-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; position: relative; box-shadow: var(--shadow); }
.step-card:hover { border-color: #cfcbff; }
.step-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.step-card .n { font-size: 12px; color: var(--accent-ink); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.step-card .s { font-weight: 600; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-card .del { position: absolute; top: 8px; right: 8px; }
.wait { display: flex; align-items: center; gap: 8px; padding: 8px 0 8px 18px; border-left: 2px dashed #d6d3f5; margin-left: 20px; color: var(--ink-2); font-size: 13px; }
.wait input { width: 64px; padding: 4px 8px; }
.add-step { margin-top: 12px; width: 100%; justify-content: center; border-style: dashed; }
.editor-wrap { border: 1px solid var(--line); border-radius: 8px; }
.toolbar { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: #fbfbfd; border-radius: 8px 8px 0 0; }
.toolbar button { border: 0; background: transparent; padding: 5px 9px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink-2); }
.toolbar button:hover { background: var(--line-2); color: var(--ink); }
.toolbar .sep { width: 1px; background: var(--line); margin: 3px 4px; }
.editor { min-height: 240px; padding: 14px; outline: none; line-height: 1.6; border-radius: 0 0 8px 8px; }
.editor p { margin: 0 0 .6em; }
.var-menu { position: relative; }
.var-menu .menu { position: absolute; top: 100%; left: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(22,21,43,.14); padding: 6px; min-width: 230px; display: none; max-height: 320px; overflow: auto; }
.var-menu.open .menu { display: block; }
.menu button { display: flex; width: 100%; justify-content: space-between; text-align: left; gap: 12px; }
.menu button code { background: none; color: var(--ink-3); }
.ab-tabs { display: inline-flex; background: var(--line-2); border-radius: 8px; padding: 3px; }
.ab-tabs button { border: 0; background: transparent; padding: 5px 14px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.ab-tabs button.on { background: #fff; color: var(--accent-ink); box-shadow: var(--shadow); }
.preview-frame { width: 100%; height: 360px; border: 0; background: #fff; }
.mail-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mail-head div { margin: 2px 0; }
.warn { background: var(--amber-2); color: #7a5300; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.info { background: var(--blue-2); color: #144d8c; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.ok-box { background: var(--green-2); color: #0b6b46; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

.days { display: flex; gap: 6px; }
.days label { cursor: pointer; }
.days input { display: none; }
.days span { display: grid; place-items: center; width: 40px; height: 34px; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; color: var(--ink-2); }
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Modale / panneau */
.overlay { position: fixed; inset: 0; background: rgba(22, 21, 43, .42); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .12s; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(22,21,43,.3); }
.modal.wide { width: min(900px, 100%); }
.modal-h { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h2 { flex: 1; }
.modal-b { padding: 20px 22px; overflow: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.drawer-ov { position: fixed; inset: 0; background: rgba(22,21,43,.3); z-index: 40; animation: fade .12s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: #fff; z-index: 41; box-shadow: -20px 0 60px rgba(22,21,43,.18); display: flex; flex-direction: column; animation: slide .16s ease-out; }
.drawer .modal-b { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 380px; animation: slide .16s; font-size: 13.5px; }
.toast.err { background: var(--red); }

.secret { font-family: ui-monospace, Menlo, monospace; background: var(--line-2); padding: 10px 12px; border-radius: 8px; word-break: break-all; font-size: 13px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li { padding: 0 0 14px 16px; position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.timeline time { display: block; color: var(--ink-3); font-size: 12px; }
.bulkbar { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px; margin-bottom: 12px; }
.bulkbar .btn { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.bulkbar .btn:hover { background: rgba(255,255,255,.2); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }
.dropdown { position: relative; display: inline-block; }
.dropdown .menu { right: 0; left: auto; }
.dropdown.open .menu { display: block; }
.dropdown .menu { position: absolute; top: calc(100% + 4px); z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(22,21,43,.14); padding: 5px; min-width: 190px; display: none; }
.menu button { border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--line-2); }
.menu hr { margin: 4px 0; }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none !important; } }
.auth-form { display: grid; place-items: center; padding: 40px; }
.auth-form form { width: min(380px, 100%); }
.auth-art { background: var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth-art h2 { font-size: 30px; line-height: 1.2; font-weight: 750; max-width: 460px; letter-spacing: -.02em; }
.auth-art p { color: #b9b8d3; max-width: 440px; line-height: 1.6; }
.auth-art ul { list-style: none; padding: 0; margin: 22px 0 0; color: #d9d8ec; }
.auth-art li { padding: 6px 0; }
.auth-art li::before { content: "→ "; color: #9b90ff; }
.glow { position: absolute; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(circle, rgba(123,109,255,.45), transparent 65%); right: -140px; top: -120px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { padding: 60px; text-align: center; color: var(--ink-3); }
.sf-logo { width: 38px; height: 26px; }

/* Réponses */
.nav-badge { margin-left: auto; background: #12a46b; color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; min-width: 20px; text-align: center; }
.reply-row { cursor: pointer; }
.reply-row:hover { background: #fafaff; }
.reply-row.unread { box-shadow: inset 3px 0 0 var(--green); }
.reply-row.unread .txt > .row b:first-child { font-weight: 750; }
