/* ============================================================
   Plateforme de confiance numérique — design tokens
   Sobre & institutionnel · accent bleu encre · vert discret
   ============================================================ */

:root {
  /* surfaces & neutrals (cool, low-chroma) */
  --bg:            oklch(0.984 0.004 247);
  --surface:       #ffffff;
  --surface-2:     oklch(0.975 0.005 247);
  --surface-3:     oklch(0.962 0.006 247);
  --border:        oklch(0.918 0.006 247);
  --border-strong: oklch(0.858 0.009 247);

  --text:   oklch(0.255 0.022 255);
  --text-2: oklch(0.475 0.018 255);
  --text-3: oklch(0.615 0.014 255);

  /* accent — bleu encre (réglable via tweak) */
  --primary:        oklch(0.42 0.108 255);
  --primary-strong: oklch(0.345 0.118 257);
  --primary-soft:   oklch(0.952 0.024 255);
  --primary-ring:   oklch(0.42 0.108 255 / 0.28);

  /* états */
  --green:      oklch(0.55 0.085 156);
  --green-soft: oklch(0.955 0.03 156);
  --amber:      oklch(0.66 0.115 72);
  --amber-soft: oklch(0.96 0.045 80);
  --red:        oklch(0.55 0.16 26);
  --red-soft:   oklch(0.957 0.035 26);
  --violet:     oklch(0.52 0.12 290);
  --violet-soft:oklch(0.955 0.03 290);

  /* density (réglable) */
  --pad: 24px;
  --gap: 16px;
  --row-h: 44px;

  --radius:   10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px oklch(0.4 0.03 255 / 0.06), 0 1px 3px oklch(0.4 0.03 255 / 0.05);
  --shadow-md: 0 2px 6px oklch(0.4 0.03 255 / 0.07), 0 8px 24px oklch(0.4 0.03 255 / 0.07);
  --shadow-lg: 0 12px 40px oklch(0.35 0.04 255 / 0.16);

  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  --sidebar-w: 256px;
}

[data-density="compact"] { --pad: 16px; --gap: 11px; --row-h: 38px; }
[data-density="comfy"]   { --pad: 30px; --gap: 20px; --row-h: 50px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100%; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--primary-soft); }

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100%; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brandmark {
  width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 600; font-size: 15px; letter-spacing: -0.02em;
  color: #fff; flex: none;
  font-family: var(--sans);
}
.brand__name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; line-height: 1.15; }
.brand__sub { font-size: 11px; color: var(--text-3); letter-spacing: 0.02em; }

.sidebar__scroll { flex: 1; overflow-y: auto; padding: 12px 12px 16px; }
.nav-group__label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); padding: 14px 10px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.nav-item__badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
  border-radius: 20px; padding: 1px 8px; min-width: 20px; text-align: center;
}
.nav-item.is-active .nav-item__badge { background: #fff; color: var(--primary-strong); }

.sidebar__foot {
  border-top: 1px solid var(--border); padding: 12px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
}

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 60px; flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 var(--pad);
  background: oklch(0.984 0.004 247 / 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.topbar__crumb { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.topbar__spacer { flex: 1; }
.hamburger { display: none; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 11px; color: var(--text-3);
  font-size: 13px; min-width: 220px;
}
.search input { border: none; background: none; outline: none; color: var(--text); width: 100%; font-size: 13px; }

.content { flex: 1; overflow-y: auto; }
.page { padding: var(--pad); max-width: 1280px; margin: 0 auto; }
.page--wide { max-width: 1500px; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: var(--pad); flex-wrap: wrap; }
.page-head__txt { flex: 1 1 280px; min-width: 0; }
.page-head__txt h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.page-head__txt p { margin: 5px 0 0; color: var(--text-2); font-size: 13.5px; max-width: 60ch; }
.page-head__actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  padding: 0 14px; height: 38px; font-size: 13.5px; font-weight: 500;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .04s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(0.5px); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 7px; }
.btn--icon { width: 38px; padding: 0; }
.btn--sm.btn--icon { width: 32px; }
.btn--danger { color: var(--red); }
.btn--danger:hover { background: var(--red-soft); border-color: var(--red); }

/* ---------- Cards & surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card__head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card__head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card__head p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.card__body { padding: 18px; }
.card__foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }

.grid { display: grid; gap: var(--gap); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- KPI ---------- */
.kpi { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi__ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi__ic svg { width: 18px; height: 18px; }
.kpi__val { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; font-family: var(--mono); }
.kpi__val small { font-size: 14px; color: var(--text-3); font-weight: 500; }
.kpi__delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.kpi__delta.up { color: var(--green); }
.kpi__delta.down { color: var(--red); }
.kpi__delta.flat { color: var(--text-3); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 4px 9px; border-radius: 20px; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--green  { background: var(--green-soft);  color: oklch(0.42 0.09 156); }
.badge--blue   { background: var(--primary-soft); color: var(--primary-strong); }
.badge--amber  { background: var(--amber-soft);  color: oklch(0.5 0.12 60); }
.badge--red    { background: var(--red-soft);    color: oklch(0.48 0.16 26); }
.badge--violet { background: var(--violet-soft); color: oklch(0.45 0.13 290); }
.badge--gray   { background: var(--surface-3);   color: var(--text-2); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-3);
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-family: var(--mono); text-align: right; font-feature-settings: "tnum" 1; }

/* ---------- Service tile ---------- */
.svc-ic { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.svc-ic svg { width: 21px; height: 21px; }

/* ---------- Progress / meters ---------- */
.meter { height: 7px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); }

/* ---------- Misc ---------- */
.muted { color: var(--text-3); }
.divider { height: 1px; background: var(--border); border: none; margin: 0; }
.tag {
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 5px;
}
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty svg { width: 34px; height: 34px; margin-bottom: 10px; opacity: .5; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: none; background: none; padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: oklch(0.3 0.03 255 / 0.4);
  display: grid; place-items: center; padding: 24px;
  animation: fade .14s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  animation: pop .16s cubic-bezier(.2,.9,.3,1.2);
}
.modal--lg { max-width: 880px; }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal__head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slidein { from { opacity: 0; transform: translateX(8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes scenein { from { opacity: 0; transform: translateY(6px); } }
.spin { animation: spin .8s linear infinite; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.input, .select, .textarea {
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 11px; font-size: 13.5px; color: var(--text); background: var(--surface);
  width: 100%; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.textarea { resize: vertical; min-height: 72px; }

/* ---------- Journey builder ---------- */
.flowwrap { display: grid; grid-template-columns: 1fr 300px; gap: var(--gap); align-items: start; }
.flow { display: flex; flex-direction: column; align-items: center; padding: 8px 0 28px; }
.flow-node {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 13px;
  padding: 13px 15px; position: relative; transition: border-color .12s, box-shadow .12s, transform .1s;
}
.flow-node.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.flow-node__grip { color: var(--text-3); cursor: grab; display: grid; place-items: center; }
.flow-node__txt { flex: 1; min-width: 0; }
.flow-node__name { font-weight: 600; font-size: 13.5px; }
.flow-node__sub { font-size: 12px; color: var(--text-3); }
.flow-node__acts { display: flex; gap: 3px; opacity: 0; transition: opacity .12s; }
.flow-node:hover .flow-node__acts { opacity: 1; }

.prov-pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px 3px 4px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
@media (max-width: 640px) { .prov-pill span { display: none; } .prov-pill { padding: 4px; } }

.flow-cap {
  width: 100%; max-width: 560px; display: flex; align-items: center; gap: 11px; justify-content: center;
  padding: 11px 16px; border-radius: 24px; font-weight: 600; font-size: 13px;
}
.flow-cap--start { background: var(--text); color: #fff; }
.flow-cap--end { background: var(--surface); border: 1.5px solid var(--border-strong); color: var(--text-2); }

.flow-gate {
  width: 100%; max-width: 560px; background: var(--amber-soft);
  border: 1px solid oklch(0.8 0.09 75); border-radius: var(--radius);
  padding: 12px 15px; display: flex; align-items: center; gap: 13px;
}
.flow-gate .gw { width: 30px; height: 30px; transform: rotate(45deg); background: var(--amber); border-radius: 6px; flex: none; display: grid; place-items: center; }
.flow-gate .gw svg { transform: rotate(-45deg); width: 16px; height: 16px; color: #fff; }

.flow-link { width: 2px; height: 18px; background: var(--border-strong); }
.flow-add {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px dashed var(--border-strong);
  background: var(--surface); color: var(--text-3); display: grid; place-items: center;
  margin: 4px 0; transition: all .12s; z-index: 2;
}
.flow-add:hover { border-color: var(--primary); color: var(--primary); border-style: solid; transform: scale(1.12); }
.flow-add svg { width: 15px; height: 15px; }

.palette-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  text-align: left; width: 100%; transition: border-color .12s, background .12s, transform .08s;
}
.palette-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.palette-item:active { transform: scale(.99); }

/* ---------- Form builder ---------- */
.fb { display: grid; grid-template-columns: 220px 1fr 280px; gap: var(--gap); align-items: start; }
.fb-canvas { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; min-height: 460px; box-shadow: var(--shadow-sm); }
.fb-field { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; margin-bottom: 11px; background: var(--surface); transition: border-color .12s, box-shadow .12s; position: relative; }
.fb-field.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.fb-field:hover { border-color: var(--border-strong); }
.fb-field__label { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.fb-field__req { color: var(--red); }
.fb-mock { border: 1px solid var(--border-strong); border-radius: 7px; padding: 8px 10px; background: var(--surface-2); color: var(--text-3); font-size: 13px; }
.fb-field__acts { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.fb-field:hover .fb-field__acts { opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .flowwrap { grid-template-columns: 1fr; }
  .fb { grid-template-columns: 1fr; }
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: oklch(0.3 0.03 255 / 0.35); z-index: 55; }
  .hamburger { display: inline-flex; }
  .cols-3 { grid-template-columns: 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .search { display: none; }
}
@media (max-width: 560px) {
  .cols-4 { grid-template-columns: 1fr; }
  .page-head__actions { width: 100%; }
}
