:root {
  --cp-navy: #0B3A6E;
  --cp-navy-deep: #07284d;
  --cp-blue: #1B6CA8;
  --cp-blue-soft: #E8F1F8;
  --cp-sky: #4FA3D1;
  --cp-ink: #142033;
  --cp-muted: #5B6B7C;
  --cp-line: #D7E0EA;
  --cp-paper: #F4F7FB;
  --cp-white: #FFFFFF;
  --cp-ok: #1F7A4C;
  --cp-warn: #B86E00;
  --cp-danger: #B42318;
  --cp-sidebar: 268px;
  --cp-radius: 16px;
  --cp-shadow: 0 18px 40px rgba(11, 58, 110, .10);
  --cp-brand-rgb: 27, 108, 168;
  --cp-font: "Source Sans 3", "Segoe UI", sans-serif;
  --cp-display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--cp-font);
  color: var(--cp-ink);
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(var(--cp-brand-rgb), .16), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(var(--cp-brand-rgb), .10), transparent 55%),
    var(--cp-paper);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

.muted { color: var(--cp-muted); }
.tiny { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--cp-muted); }

/* ——— Marketing / landing ——— */
.cp-landing {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.cp-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 64px);
}
.cp-brand {
  display: flex; align-items: center; gap: 12px;
}
.cp-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, var(--cp-blue), var(--cp-navy));
  color: #fff; display: grid; place-items: center;
  font-family: var(--cp-display); font-weight: 700; font-size: 18px;
  box-shadow: 0 10px 24px rgba(var(--cp-brand-rgb), .25);
}
.cp-brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  object-fit: cover; background: #05070d;
  box-shadow: 0 8px 18px rgba(11, 58, 110, .18);
  flex: 0 0 auto;
}
.cp-brand-mark--light,
.side-brand .cp-brand-mark--light {
  background: #fff;
  object-fit: contain;
  padding: 3px;
  box-sizing: border-box;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
}
.cp-brand-word {
  display: block; height: 44px; width: auto; max-width: min(260px, 70vw);
  object-fit: contain;
}
.cp-brand--on-dark .cp-brand-word {
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.25));
  height: 64px; max-width: min(380px, 85vw);
}
.cp-brand--stacked .cp-brand-mark { width: 48px; height: 48px; }
.cp-brand strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.cp-brand span { display: block; font-size: 12px; color: var(--cp-muted); }
.cp-top-actions { display: flex; gap: 10px; align-items: center; }

.cp-hero {
  position: relative;
  padding: clamp(40px, 8vw, 96px) clamp(20px, 5vw, 64px) 72px;
  overflow: hidden;
}
.cp-hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(120deg, rgba(244,247,251,.92) 0%, rgba(244,247,251,.55) 42%, rgba(11,58,110,.08) 100%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230B3A6E' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  z-index: 0;
}
.cp-hero-inner {
  position: relative; z-index: 1;
  max-width: 720px;
}
.cp-hero .eyebrow {
  display: inline-block; margin-bottom: 18px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--cp-blue-soft); color: var(--cp-navy);
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
}
.cp-hero h1 {
  margin: 0 0 16px;
  font-family: var(--cp-display);
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.02; letter-spacing: -.03em;
  color: var(--cp-navy-deep);
}
.cp-hero h1 em {
  font-style: normal;
  background: linear-gradient(90deg, var(--cp-blue), var(--cp-navy));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cp-hero p.lead {
  margin: 0 0 28px; font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.55; color: var(--cp-muted); max-width: 54ch;
}
.cp-hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.cp-hero-visual {
  position: absolute; right: clamp(12px, 6vw, 80px); top: 18%;
  width: min(420px, 38vw); aspect-ratio: 4/5;
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(27,108,168,.92), rgba(7,40,77,.96)),
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.25), transparent 45%);
  box-shadow: var(--cp-shadow);
  color: #fff; padding: 28px;
  display: none;
  transform: rotate(2deg);
}
@media (min-width: 980px) {
  .cp-hero-visual { display: flex; flex-direction: column; justify-content: space-between; }
}
.cp-hero-visual .sheet {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  border-radius: 16px; padding: 16px; backdrop-filter: blur(6px);
}
.cp-hero-visual .sheet + .sheet { margin-top: 12px; }
.cp-section {
  padding: 56px clamp(20px, 5vw, 64px);
}
.cp-section h2 {
  font-family: var(--cp-display); font-size: clamp(28px, 3.5vw, 40px);
  margin: 0 0 10px; color: var(--cp-navy-deep); letter-spacing: -.02em;
}
.cp-grid-3 {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 28px;
}
.cp-feature {
  padding: 22px; border-radius: 18px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(215,224,234,.9);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
}
.cp-feature h3 { margin: 0 0 8px; font-size: 18px; color: var(--cp-navy); }
.cp-feature p { margin: 0; color: var(--cp-muted); line-height: 1.5; }
.cp-footer {
  padding: 28px clamp(20px, 5vw, 64px);
  border-top: 1px solid var(--cp-line);
  color: var(--cp-muted); font-size: 14px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ——— Buttons ——— */
.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px;
  font-weight: 650; font-size: 14px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--cp-blue), var(--cp-navy));
  color: #fff; box-shadow: 0 10px 24px rgba(var(--cp-brand-rgb), .22);
}
.btn-ghost {
  background: transparent; color: var(--cp-navy);
  border: 1px solid var(--cp-line);
}
.btn-soft {
  background: var(--cp-blue-soft); color: var(--cp-navy);
}
.btn-danger { background: #fdeceb; color: var(--cp-danger); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ——— Auth ——— */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
}
.login-visual {
  position: relative;
  background:
    linear-gradient(165deg, rgba(7,40,77,.92) 0%, rgba(11,58,110,.82) 48%, rgba(27,108,168,.72) 100%),
    radial-gradient(circle at 18% 18%, rgba(255,255,255,.16), transparent 42%),
    var(--cp-navy-deep);
  color: #fff;
  padding: clamp(36px, 6vw, 64px);
  display: flex; align-items: center;
}
.login-visual-copy {
  max-width: 520px;
  display: grid;
  gap: 18px;
}
.login-visual-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 16px 22px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(0,0,0,.22);
  max-width: min(100%, 440px);
}
.login-visual-logo {
  display: block;
  height: clamp(78px, 11vw, 112px);
  width: auto;
  max-width: min(380px, 100%);
  object-fit: contain;
}
.cp-brand--login-form .cp-brand-mark--light {
  width: 52px;
  height: 52px;
  background: #fff;
  border: 1px solid var(--cp-line);
  padding: 4px;
  box-sizing: border-box;
  object-fit: contain;
}
.login-visual-kicker {
  margin: 0;
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.72);
  font-weight: 600;
}
.login-visual h1 {
  font-family: var(--cp-display);
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1.12;
  margin: 0;
  letter-spacing: -.02em;
  max-width: 18ch;
  font-weight: 700;
}
.login-visual-lead {
  margin: 0;
  line-height: 1.65;
  color: rgba(255,255,255,.86);
  max-width: 42ch;
  font-size: 16px;
}
.login-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px; background: var(--cp-paper);
}
.login-card {
  width: min(420px, 100%);
  background: #fff; border: 1px solid var(--cp-line);
  border-radius: 22px; padding: 28px;
  box-shadow: var(--cp-shadow);
}
.login-card h2 { margin: 18px 0 6px; font-size: 24px; color: var(--cp-navy-deep); }
.login-card .lead { margin: 0 0 18px; color: var(--cp-muted); }
.login-card-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 18px; flex-wrap: wrap;
}
.login-remember {
  display: flex; gap: 8px; align-items: center;
  color: var(--cp-muted); font-size: 13px; margin: 0;
}
.error { color: var(--cp-danger); margin: 0 0 12px; }
.flash-ok { background: #e8f6ee; color: var(--cp-ok); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.flash-warn { background: #fff6e5; color: #8a5a00; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; border: 1px solid rgba(184,110,0,.25); }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual {
    min-height: auto; padding: 28px 24px 32px;
    align-items: flex-start;
  }
  .login-visual-copy { gap: 12px; }
  .login-visual-logo { height: 68px; }
  .login-visual-brand { padding: 12px 16px; }
  .login-visual h1 { max-width: none; font-size: 26px; }
}

/* ——— App shell ——— */
.shell { display: grid; grid-template-columns: var(--cp-sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, var(--cp-navy-deep), var(--cp-navy) 55%, var(--cp-blue));
  color: #e8eef6; padding: 18px 14px 24px; overflow: auto;
}
.side-brand {
  display: flex; gap: 12px; align-items: center; padding: 8px 8px 16px;
}
.side-brand .cp-mark,
.side-brand .cp-brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.side-brand .kicker { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; opacity: .7; }
.side-brand h1 { margin: 2px 0 0; font-size: 16px; font-weight: 700; }
.side-brand h1 span { display: block; font-size: 11px; font-weight: 500; opacity: .7; margin-top: 2px; }

.nav a .nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: #e11d48; color: #fff;
  font-size: 10px; font-weight: 700;
  display: inline-grid; place-items: center;
  line-height: 1;
}
.nav-bell {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--cp-navy);
  background: var(--cp-blue-soft);
  border: 1px solid var(--cp-line);
}
.nav-bell:hover,
.nav-bell.on {
  background: rgba(27,108,168,.14);
  color: var(--cp-navy-deep);
  border-color: rgba(27,108,168,.28);
}
.nav-bell svg {
  width: 20px; height: 20px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  transform-origin: top center;
}
.nav-bell-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  background: #e11d48; color: #fff;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}
.nav-bell.is-ringing svg {
  animation: cp-bell-ring 1.1s ease-in-out 3;
}
@keyframes cp-bell-ring {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-12deg); }
  45% { transform: rotate(10deg); }
  60% { transform: rotate(-8deg); }
  75% { transform: rotate(4deg); }
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; color: rgba(255,255,255,.82); font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 650; }
.nav svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav-group { margin: 14px 8px 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .55; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; border-bottom: 1px solid var(--cp-line);
  background: rgba(255,255,255,.72); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 18px; color: var(--cp-navy-deep); }
.content { padding: 22px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 {
  margin: 0; font-family: var(--cp-display); font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -.02em; color: var(--cp-navy-deep);
}
.page-head p { margin: 6px 0 0; color: var(--cp-muted); }

.kpi-row {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 18px;
}
.kpi {
  background: #fff; border: 1px solid var(--cp-line); border-radius: 16px;
  padding: 16px 18px; box-shadow: 0 8px 20px rgba(11,58,110,.04);
}
.kpi .label { font-size: 12px; color: var(--cp-muted); text-transform: uppercase; letter-spacing: .08em; }
.kpi .value { margin-top: 6px; font-size: 28px; font-weight: 700; color: var(--cp-navy); font-family: var(--cp-display); }

.panel {
  background: #fff; border: 1px solid var(--cp-line); border-radius: 18px;
  box-shadow: 0 10px 28px rgba(11,58,110,.05);
  /* visible : les menus autocomplete ne doivent pas être rognés */
  overflow: visible;
}
.panel-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--cp-line);
  border-radius: 18px 18px 0 0;
}
.panel-hd h3 { margin: 0; font-size: 15px; color: var(--cp-navy-deep); }
.panel-bd { padding: 18px; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-top: 14px;
}
.pager-meta { font-size: 13px; }
.pager-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.pager-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--cp-line);
  background: #fff; color: var(--cp-navy); font-size: 13px; font-weight: 650;
  text-decoration: none; box-sizing: border-box;
}
a.pager-btn:hover { background: var(--cp-blue-soft); border-color: rgba(27,108,168,.25); }
.pager-btn.is-current {
  background: var(--cp-navy); color: #fff; border-color: var(--cp-navy);
}
.pager-btn.is-disabled { opacity: .4; cursor: default; pointer-events: none; }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--cp-line); vertical-align: top;
}
table.data th {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--cp-muted); background: #fafcfe;
}
table.data tr:hover td { background: #f8fbfe; }

/* Master-detail (liste + fiche) */
.cp-md {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 16px;
  align-items: start;
}
.cp-md-list .table-wrap {
  border: 1px solid var(--cp-line);
  border-radius: 14px;
  overflow: auto;
}
.cp-md-row { cursor: pointer; }
.cp-md-row.is-active td {
  background: var(--cp-blue-soft);
}
.cp-md-fiche {
  border: 1px solid var(--cp-line);
  border-radius: 14px;
  padding: 16px;
  background: #fafcfe;
  min-height: 180px;
}
.cp-md-fiche h4 { font-size: 16px; color: var(--cp-navy-deep); font-weight: 700; }
.cp-md-pane[hidden] { display: none !important; }
.cp-md-pager { margin-top: 10px; }
.cp-md-pager .pager { margin-top: 0; }
@media (max-width: 960px) {
  .cp-md { grid-template-columns: 1fr; }
}

.badge {
  display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--cp-blue-soft); color: var(--cp-navy);
}
.badge-urgent { background: #fdeceb; color: var(--cp-danger); }
.badge-high { background: #fff4e5; color: var(--cp-warn); }
.badge-ok { background: #e8f6ee; color: var(--cp-ok); }
.badge-muted { background: #eef2f6; color: var(--cp-muted); }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 650; color: var(--cp-navy-deep); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--cp-line); background: #fff; color: var(--cp-ink); font-size: 14px;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(var(--cp-brand-rgb), .25); border-color: var(--cp-blue);
}
.field-hint { margin-top: 6px; font-size: 12px; color: var(--cp-muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a, .tabs button {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 12px; border-radius: 999px; color: var(--cp-muted); font-weight: 650; font-size: 13px;
}
.tabs a.on, .tabs button.on { background: var(--cp-blue-soft); color: var(--cp-navy); }
.cp-tab-panels > [data-cp-tab-panel][hidden] { display: none !important; }

/* Autocomplete — menu en fixed (porté sur body) pour échapper overflow panels/modales/tables */
.cp-ac-control { position: relative; }
.cp-ac-input { width: 100%; padding-right: 36px !important; }
.cp-ac-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--cp-muted); cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px; font-size: 18px; line-height: 1;
}
.cp-ac-clear:hover { background: var(--cp-blue-soft); color: var(--cp-navy); }
.cp-ac-menu {
  position: fixed; z-index: 400; left: 0; top: 0; right: auto; bottom: auto;
  min-width: 180px; width: max-content; max-width: min(420px, calc(100vw - 16px));
  background: #fff; border: 1px solid var(--cp-line); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(11,58,110,.18); max-height: 260px; overflow: auto; padding: 6px;
  box-sizing: border-box;
}
.cp-ac-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 10px 12px; border-radius: 10px; color: var(--cp-ink);
}
.cp-ac-option:hover, .cp-ac-option:focus { background: var(--cp-blue-soft); outline: none; }
.cp-ac-option span { font-size: 12px; color: var(--cp-muted); }
.cp-ac-empty { padding: 12px; color: var(--cp-muted); font-size: 13px; }
.cp-ac.is-disabled { opacity: .55; pointer-events: none; }
.cp-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--cp-blue-soft); color: var(--cp-navy);
  border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 650;
}
.cp-chip button {
  border: 0; background: transparent; cursor: pointer; color: var(--cp-navy); font-size: 14px;
}
.cp-chip--btn {
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.cp-chip--btn:hover,
.cp-chip--btn.is-active {
  border-color: var(--cp-blue);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(var(--cp-brand-rgb), .12);
}
.cp-chip--btn .muted { font-weight: 500; color: var(--cp-muted); }

.cp-callout {
  background: linear-gradient(120deg, rgba(232,241,248,.95), rgba(255,255,255,.9));
  border: 1px solid var(--cp-line);
  border-left: 4px solid var(--cp-blue);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.cp-callout strong { display: block; color: var(--cp-navy-deep); margin-bottom: 4px; }
.cp-callout p { margin: 0; color: var(--cp-muted); line-height: 1.5; }
.cp-callout a { color: var(--cp-blue); font-weight: 650; text-decoration: underline; }

.settings-split {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  min-height: 420px;
}
@media (max-width: 900px) {
  .settings-split { grid-template-columns: 1fr; }
}
.settings-side {
  border-right: 1px solid var(--cp-line);
  padding-right: 14px;
}
@media (max-width: 900px) {
  .settings-side { border-right: 0; border-bottom: 1px solid var(--cp-line); padding-right: 0; padding-bottom: 14px; }
}
.settings-side-list { display: grid; gap: 6px; }
.settings-side-item {
  display: block; padding: 10px 12px; border-radius: 12px;
  border: 1px solid transparent; background: #f7fafc;
}
.settings-side-item strong { display: block; color: var(--cp-navy-deep); }
.settings-side-item span { display: block; font-size: 12px; color: var(--cp-muted); margin-top: 2px; }
.settings-side-item:hover { border-color: var(--cp-line); }
.settings-side-item.on {
  background: var(--cp-blue-soft);
  border-color: rgba(27,108,168,.25);
}
.settings-main { min-width: 0; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.cp-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.cp-check {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--cp-line);
  background: #fff; cursor: pointer; font-size: 13px;
}
.cp-check:has(input:checked) {
  background: var(--cp-blue-soft);
  border-color: rgba(27,108,168,.3);
}

.letter-a4 {
  /* Repère A4 = PDF : marges 15/20/18/20 mm → padding % de largeur (ratio A4). */
  --cp-a4-pad: 7.143% 9.524% 8.571% 9.524%;
  position: relative;
  width: min(794px, 100%);
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--cp-line);
  box-shadow: var(--cp-shadow);
  padding: var(--cp-a4-pad);
  box-sizing: border-box;
  overflow: hidden;
}
.letter-a4.letter-a4--signable { user-select: none; }
.cp-sig-layer {
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 5;
}
.cp-sig-handle {
  position: absolute;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  /* Pas de padding/border : left/top/width % = même boîte image que le PDF. */
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  box-shadow: none;
  outline: 1.5px dashed rgba(11,58,110,.45);
  outline-offset: 2px;
}
.letter-a4:not(.letter-a4--signable) .cp-sig-handle {
  outline: none;
}
.cp-sig-handle:active { cursor: grabbing; }
.cp-sig-handle img {
  display: block; width: 100%; height: auto;
  pointer-events: none;
  background: transparent;
}
.cp-sig-handle .cp-sig-resize {
  position: absolute; right: -8px; bottom: -8px;
  width: 14px; height: 14px; border-radius: 3px;
  background: var(--cp-navy); cursor: nwse-resize;
  border: 2px solid #fff;
}
.cp-sig-pad {
  border: 1px solid var(--cp-line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.cp-sig-pad canvas {
  display: block; width: 100%; height: 280px; /* +75% vs 160px */
  touch-action: none; cursor: crosshair;
  background:
    linear-gradient(transparent 78%, rgba(11,58,110,.08) 78%, rgba(11,58,110,.08) 79%, transparent 79%);
}
.cp-sig-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.cp-sig-steps {
  margin: 0; padding: 12px 12px 12px 28px;
  background: var(--cp-blue-soft); border-radius: 12px;
  color: var(--cp-navy-deep); line-height: 1.55; font-size: 14px;
}
.cp-sig-steps li { margin: 4px 0; }
.cp-sig-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 4px; padding-top: 8px;
  border-top: 1px solid var(--cp-line);
}
.cp-sig-preview-actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-top: 14px; padding: 12px 14px;
  background: var(--cp-blue-soft); border-radius: 12px;
}
.letter-a4 .lh-head {
  display: flex; justify-content: space-between; gap: 16px;
  border-bottom: 3px solid var(--cp-navy); padding-bottom: 14px; margin-bottom: 28px;
}
.letter-a4 .lh-brand { min-width: 0; flex: 1; }
.letter-a4 .lh-logo {
  display: block; max-height: 56px; max-width: 140px;
  width: auto; height: auto; object-fit: contain; margin: 0 0 10px;
}
.letter-a4 .lh-org { font-family: var(--cp-display); font-size: 22px; color: var(--cp-navy); line-height: 1.2; }
.letter-a4 .lh-tagline { font-size: 13px; color: var(--cp-muted); margin: 4px 0 8px; }
.letter-a4 .meta { font-size: 13px; color: var(--cp-muted); line-height: 1.5; }
.letter-a4 .object { margin: 22px 0; font-weight: 700; }
.letter-a4 .body { white-space: normal; line-height: 1.7; }
.letter-a4 .sign {
  position: relative;
  margin-top: 42px;
  /* Pas de padding-top : la signature est en overlay (z-index), elle ne pousse pas le texte. */
}
.letter-a4 .sign .cp-sig-handle {
  z-index: 40;
  background: transparent;
}

.disabled-block { opacity: .55; pointer-events: none; filter: grayscale(.2); }
.stack { display: grid; gap: 16px; }
.split {
  display: grid; gap: 18px;
  grid-template-columns: 1.1fr .9fr;
}
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px;
}
.filters .field { margin: 0; min-width: 160px; }
.filters .field.grow { flex: 1; min-width: 220px; }

.empty {
  padding: 36px 18px; text-align: center; color: var(--cp-muted);
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 30, 55, .45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(640px, 100%); background: #fff; border-radius: 18px;
  border: 1px solid var(--cp-line); box-shadow: var(--cp-shadow);
  max-height: min(90vh, 920px);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 0;
}
.modal.modal--scroll { overflow: auto; }
.modal.modal--wide { width: min(820px, 100%); }
/* Formulaire = colonne flex pour coller le footer en bas sur toute la largeur */
.modal > form,
.modal > form.stack {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  gap: 0;
  margin: 0;
}
.modal-hd {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--cp-line);
  flex: 0 0 auto;
  background: #fff;
}
.modal-hd h3 { margin: 0; }
.modal-bd {
  padding: 18px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.modal-ft {
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 14px 18px;
  border-top: 1px solid var(--cp-line);
  background: #fff;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.modal-ft > .btn { flex: 0 0 auto; }
.modal-ft.cp-wizard-ft { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.modal-ft .cp-wizard-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

/* ——— Step-by-step wizard / process ——— */
.cp-stepper {
  display: flex; align-items: flex-start; gap: 0;
  margin: 0 0 18px; flex-wrap: nowrap; overflow-x: auto;
  padding-bottom: 4px;
}
.cp-step {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 0; flex: 1 1 0;
}
.cp-step-num {
  width: 28px; height: 28px; border-radius: 999px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  border: 1.5px solid var(--cp-line);
  background: #fff; color: var(--cp-muted);
}
.cp-step-copy { min-width: 0; padding-top: 2px; }
.cp-step-label {
  font-size: 12px; font-weight: 650; letter-spacing: .02em;
  color: var(--cp-muted); line-height: 1.25;
}
.cp-step-hint {
  font-size: 11px; color: var(--cp-muted); opacity: .85; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cp-step-rail {
  width: 18px; min-width: 12px; height: 2px; margin: 13px 6px 0;
  background: var(--cp-line); flex: 0 0 auto; align-self: flex-start;
}
.cp-step--current .cp-step-num {
  border-color: var(--cp-navy); background: var(--cp-navy); color: #fff;
}
.cp-step--current .cp-step-label { color: var(--cp-ink); }
.cp-step--done .cp-step-num {
  border-color: var(--cp-ok); background: rgba(31,122,76,.12); color: var(--cp-ok);
}
.cp-step--done .cp-step-label { color: var(--cp-ink); }
.cp-step--done + .cp-step-rail,
.cp-step--current + .cp-step-rail { background: rgba(27,108,168,.35); }

.cp-stepper--process {
  background: #fff; border: 1px solid var(--cp-line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 16px; box-shadow: 0 8px 20px rgba(11,58,110,.04);
}
.cp-wizard-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin: 0 0 12px; flex-wrap: wrap;
}
.cp-wizard-meta .counter {
  font-size: 12px; color: var(--cp-muted); letter-spacing: .04em;
}
.cp-wizard-meta .title {
  font-family: var(--cp-display); font-size: 18px; margin: 0; color: var(--cp-navy);
}
.cp-wizard-panel[hidden] { display: none !important; }
.cp-wizard-recap {
  display: grid; gap: 10px;
  background: var(--cp-blue-soft); border-radius: 12px; padding: 14px;
}
.cp-wizard-recap .row {
  display: grid; grid-template-columns: 140px 1fr; gap: 8px; font-size: 14px;
}
.cp-wizard-recap .row .k { color: var(--cp-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
@media (max-width: 720px) {
  .cp-step-hint { display: none; }
  .cp-wizard-recap .row { grid-template-columns: 1fr; }
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 16px 18px;
  border-left: 2px solid var(--cp-line);
}
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 4px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--cp-blue);
}
.timeline .when { font-size: 12px; color: var(--cp-muted); }

.cp-chain { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.cp-chain-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding: 0 0 14px;
}
.cp-chain-item:last-child { padding-bottom: 0; }
.cp-chain-rail {
  position: relative;
  width: 18px;
}
.cp-chain-rail::before {
  content: "";
  position: absolute;
  left: 7px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--cp-blue);
  box-shadow: 0 0 0 3px rgba(27,108,168,.12);
}
.cp-chain-item:not(:last-child) .cp-chain-rail::after {
  content: "";
  position: absolute;
  left: 11px; top: 16px; bottom: -14px;
  width: 2px;
  background: rgba(27,108,168,.18);
}
.cp-chain-item.is-current .cp-chain-rail::before {
  background: var(--cp-ok, #1a7f4b);
  box-shadow: 0 0 0 3px rgba(26,127,75,.15);
}
.cp-chain-card {
  border: 1px solid var(--cp-line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}
.cp-chain-item.is-current .cp-chain-card {
  border-color: rgba(26,127,75,.35);
  background: rgba(232,246,238,.45);
}
.cp-chain-top { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cp-chain-title { font-size: 15px; }
.cp-chain-meta {
  display: flex; flex-wrap: wrap; gap: 10px 16px;
  margin-top: 8px; font-size: 12px; color: var(--cp-muted);
}

/* ——— Rich text editor ——— */
.cp-editor {
  border: 1px solid var(--cp-line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.cp-editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px;
  background: linear-gradient(180deg, #f7fafc, #eef3f8);
  border-bottom: 1px solid var(--cp-line);
}
.cp-editor-toolbar button,
.cp-editor-toolbar select {
  border: 1px solid var(--cp-line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--cp-ink);
  cursor: pointer;
  min-height: 30px;
}
.cp-editor-toolbar button:hover,
.cp-editor-toolbar select:hover { border-color: var(--cp-blue); }
.cp-editor-toolbar button:active { background: var(--cp-blue-soft); }
.cp-editor-sep {
  width: 1px; height: 22px; background: var(--cp-line); margin: 0 2px;
}
.cp-editor-surface {
  padding: 14px 16px;
  min-height: 180px;
  outline: none;
  line-height: 1.65;
  font-size: 15px;
}
.cp-editor-surface:focus {
  box-shadow: inset 0 0 0 2px rgba(27,108,168,.18);
}
.cp-editor-surface p { margin: 0 0 .75em; }
.cp-editor-surface ul, .cp-editor-surface ol { margin: 0 0 .75em; padding-left: 1.4em; }
.letter-a4 .body, .letter-html-body {
  white-space: normal;
  line-height: 1.7;
}
.letter-html-body p { margin: 0 0 .8em; }
.annotation-card {
  border: 1px solid var(--cp-line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.annotation-card.open {
  border-color: rgba(184,110,0,.45);
  background: rgba(184,110,0,.06);
}
.annotation-card .meta { font-size: 12px; color: var(--cp-muted); margin-bottom: 6px; }

/* ——— Settings subnav ——— */
.cp-subnav {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 16px; padding: 4px;
  background: #eef3f8; border-radius: 14px;
}
.cp-subnav a {
  padding: 9px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 650; color: var(--cp-muted);
  text-decoration: none;
}
.cp-subnav a:hover { color: var(--cp-navy); background: rgba(255,255,255,.55); }
.cp-subnav a.on {
  background: #fff; color: var(--cp-navy-deep);
  box-shadow: 0 1px 2px rgba(15, 40, 70, .08);
}

/* ——— Letterhead cards & designer ——— */
.lh-cards { display: grid; gap: 10px; }
.lh-card {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--cp-line); border-radius: 14px;
  background: #fff; text-decoration: none; color: inherit;
}
.lh-card:hover { border-color: rgba(27,108,168,.35); background: var(--cp-blue-soft); }
.lh-card-swatch { width: 10px; height: 42px; border-radius: 6px; }
.lh-logo-preview {
  width: 88px; height: 64px; border: 1px solid var(--cp-line); border-radius: 10px;
  display: grid; place-items: center; background: #fff; overflow: hidden;
}
.lh-logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.lh-designer-grid {
  display: grid; grid-template-columns: minmax(260px, 320px) 1fr; gap: 16px; align-items: start;
}
@media (max-width: 980px) {
  .lh-designer-grid { grid-template-columns: 1fr; }
}
.lh-designer-side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.lh-zones-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.lh-zone-list { display: grid; gap: 8px; }
.lh-zone-card {
  border: 1px solid var(--cp-line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.lh-zone-card.is-selected { border-color: rgba(27,108,168,.45); box-shadow: 0 0 0 2px rgba(27,108,168,.12); }
.lh-zone-card > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: #f7fafc;
}
.lh-zone-card > summary::-webkit-details-marker { display: none; }
.lh-zone-card-vis { display: flex; margin: 0; }
.lh-zone-card-title { flex: 1; font-weight: 650; font-size: 13px; color: var(--cp-navy-deep); }
.lh-zone-card-bd { padding: 10px 12px 12px; border-top: 1px solid var(--cp-line); }
.lh-style-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: end;
}
.lh-page {
  position: relative;
  width: min(100%, 520px);
  margin: 0 auto;
  aspect-ratio: 210 / 297;
  background: #fff;
  border: 1px solid var(--cp-line);
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(15, 40, 70, .08);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.lh-zone {
  position: absolute;
  border: 1.5px dashed rgba(27,108,168,.45);
  background: rgba(27,108,168,.06);
  border-radius: 4px;
  cursor: grab;
  box-sizing: border-box;
  min-width: 24px; min-height: 14px;
  z-index: 2;
}
.lh-zone.is-dragging { cursor: grabbing; border-style: solid; background: rgba(27,108,168,.12); z-index: 5; }
.lh-zone.is-selected { border-color: var(--cp-blue); border-style: solid; box-shadow: 0 0 0 2px rgba(27,108,168,.18); z-index: 4; }
.lh-zone.is-hidden { display: none !important; }
.lh-zone[data-lh-band="footer"] { border-color: rgba(184,110,0,.45); }
.lh-zone[data-lh-band="footer"] .lh-zone-label { color: #b86e00; }
.lh-zone-label {
  position: absolute; top: 2px; left: 4px;
  font-size: 9px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--cp-blue); opacity: .85; pointer-events: none;
}
.lh-zone-body {
  height: 100%; width: 100%;
  display: flex; align-items: center; justify-content: flex-start;
  padding: 12px 6px 4px; box-sizing: border-box; overflow: hidden;
  pointer-events: none; font-size: 12px; line-height: 1.25;
}
.lh-zone-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lh-zone[data-lh-zone="accent"] .lh-zone-body { padding: 0; }
.lh-accent { width: 100%; height: 100%; border-radius: 2px; }
.lh-zone-resize {
  position: absolute; right: 0; bottom: 0;
  width: 12px; height: 12px;
  background: var(--cp-blue); border-radius: 2px 0 2px 0;
  cursor: nwse-resize; touch-action: none;
}
.lh-content-ghost {
  position: absolute; left: 8%; right: 8%; top: 30%; bottom: 12%;
  border: 1px dashed #d7e0ea; border-radius: 8px;
  display: grid; place-items: center; color: var(--cp-muted); font-size: 12px;
  pointer-events: none; background: repeating-linear-gradient(
    -45deg, transparent, transparent 6px, rgba(215,224,234,.35) 6px, rgba(215,224,234,.35) 12px
  );
}
