@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@600;700;800&family=Allura&display=swap');

:root {
  --bg: #F5F7F9;
  --surface: #ffffff;
  --border: #E4E8EC;
  --text: #2B3038;
  --muted: #5F6B76;
  --primary: #2B3038;
  --primary-hover: #3B414B;
  --primary-soft: #E7F6EC;
  --sender: #00B85C;
  --sun: #FFE600;
  --ok: #00E676;
  --grad: linear-gradient(135deg, var(--sun), var(--ok));
  --client: #FF6A00;
  --success: #178048;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 48, 56, .06), 0 4px 16px rgba(43, 48, 56, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; font-family: 'Inter Tight', Inter, sans-serif; letter-spacing: -.02em; }
.stat-value { font-family: 'Inter Tight', Inter, sans-serif; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---- Layout ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--text); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
/* Liseré dégradé sous la barre */
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--grad); }
.topbar .brand { color: #fff; }
.topbar .brand-ico { border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .15); }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .2); }
.topbar .btn:hover { background: rgba(255, 255, 255, .08); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--grad); color: var(--text); font-weight: 700; font-size: .8rem;
}
.avatar.has-photo { background: #fff; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
a.user-chip { color: inherit; text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; transition: background .15s; }
a.user-chip:hover { background: rgba(255, 255, 255, .08); }
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-size: .88rem; }
.user-chip .who span { font-size: .78rem; color: #9AA5B0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-ico { width: 32px; height: 32px; display: block; flex-shrink: 0; }
.brand-word { font-family: 'Inter Tight', Inter, sans-serif; font-weight: 700; font-size: 1.4rem; letter-spacing: -.04em; line-height: 1; white-space: nowrap; }
/* Le point du « i » devient une pastille dégradée */
.brand-word .i { position: relative; display: inline-block; letter-spacing: 0; margin-right: -.04em; }
.brand-word .i::before {
  content: ''; position: absolute; left: 50%; top: .02em; width: .24em; height: .24em;
  transform: translateX(-50%); border-radius: 50%; background: var(--grad);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}

/* ---- Forms ---- */
label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field { margin-bottom: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #EEF2F5; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; white-space: normal; text-align: center; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: .9rem; margin-bottom: 16px; }
.alert-error { background: #fdecec; color: #991b1b; }
.alert-success { background: #e8f7ee; color: #166534; }
.alert-info { background: var(--primary-soft); color: #14532D; }

/* ---- Auth ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.tabs { display: flex; gap: 4px; background: #EAEEF2; padding: 4px; border-radius: 9px; margin-bottom: 20px; }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 6px;
  font: inherit; font-weight: 500; cursor: pointer; color: var(--muted);
}
.tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ---- Dashboard ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center;
  background: var(--surface); cursor: pointer; transition: .15s; margin-bottom: 24px;
}
.dropzone.drag, .dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 16px 20px; }
.stat-value { font-size: 1.6rem; font-weight: 700; }

.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th, .doc-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.doc-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.doc-table tr:last-child td { border-bottom: 0; }
.doc-table tbody tr { cursor: pointer; }
.doc-table tbody tr:hover { background: #F8FAFC; }
.table-card { padding: 0; overflow: hidden; }
.empty { padding: 48px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-draft { background: #EAEEF2; color: #475461; }
.badge-sender_signed { background: #fff4e6; color: #b45309; }
.badge-completed { background: #e8f7ee; color: #166534; }

/* ---- Accueil « À faire » ---- */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.hello h1 { margin: 0; }
.hello p { margin: 4px 0 0; color: var(--muted); }
.hello p b { color: var(--text); }
.hello .btn svg { width: 16px; height: 16px; }
.todos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.todo {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; color: var(--text); text-decoration: none; text-align: left; font: inherit; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.todo:hover { border-color: #CBD3DA; box-shadow: var(--shadow); }
.todo .ti { width: 36px; height: 36px; border-radius: 10px; background: #EAEEF2; display: grid; place-items: center; }
.todo .ti svg { width: 18px; height: 18px; }
.todo b { font: 700 1.25rem 'Inter Tight', Inter, sans-serif; display: block; }
.todo .tl2 { color: var(--muted); font-size: .88rem; display: block; }
.todo small { display: block; margin-top: 6px; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.todo .tbtn { margin-top: auto; font-weight: 600; font-size: .88rem; display: inline-flex; gap: 6px; }
.todo.hot { background: linear-gradient(160deg, #00E676, #00A86B); color: #fff; border-color: #00A86B; }
.todo.hot:hover { border-color: #008F55; box-shadow: 0 8px 24px rgba(0, 168, 107, .25); }
.todo.hot .ti { background: rgba(255, 255, 255, .18); color: #fff; }
.todo.hot .tl2, .todo.hot small { color: #D1FAE5; }
.todo.idle { cursor: default; box-shadow: none; }
.todo.idle:hover { border-color: var(--border); }
.todo.idle .ti { background: var(--primary-soft); color: var(--sender); }
.todo.idle b { color: var(--muted); }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-head h2 { margin: 0; font-size: 1.05rem; }
.mini-tabs { display: flex; gap: 4px; background: #EAEEF2; padding: 3px; border-radius: 9px; font-size: .82rem; }
.mini-tabs a { padding: 5px 10px; border-radius: 7px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.mini-tabs a.on { background: var(--surface); color: var(--text); font-weight: 600; }
.drop-hint {
  margin-top: 12px; display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: .82rem;
  border: 1.5px dashed #C9D1D9; border-radius: 12px; padding: 12px; cursor: pointer;
}
.drop-hint svg { width: 14px; height: 14px; }
.drop-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(245, 247, 249, .88); display: grid; place-items: center;
  border: 3px dashed var(--sender); font: 600 1.1rem 'Inter Tight', Inter, sans-serif; pointer-events: none;
}

/* ---- Liste des documents (suivi en 4 étapes) ---- */
.doc-list { display: grid; gap: 10px; }
.doc-row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) auto; align-items: center; gap: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.doc-row:hover { border-color: #CBD3DA; box-shadow: var(--shadow); }
.doc-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.doc-text { min-width: 0; }
.doc-text b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-text small { display: block; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-ico { width: 34px; height: 42px; border-radius: 6px; background: #fff; border: 1px solid var(--border); position: relative; flex-shrink: 0; }
.pdf-ico::after { content: ''; position: absolute; top: 0; right: 0; width: 10px; height: 10px; background: linear-gradient(225deg, var(--bg) 50%, #DDE3E8 50%); border-bottom-left-radius: 3px; }
.pdf-ico span { position: absolute; left: 4px; bottom: 5px; font: 700 .55rem Inter, sans-serif; color: #fff; background: #D9480F; padding: 1px 3px; border-radius: 3px; }

.track { display: flex; align-items: flex-start; }
.tstep { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; font-size: .72rem; color: var(--muted); text-align: center; }
.tstep::before { content: ''; position: absolute; top: 10px; left: -50%; right: 50%; height: 2px; background: #EAEEF2; }
.tstep:first-child::before { display: none; }
.tstep i { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid #D3DAE1; display: grid; place-items: center; position: relative; z-index: 1; }
.tstep i svg { width: 11px; height: 11px; }
.tstep em { font-style: normal; white-space: nowrap; }
.tstep.done i { background: var(--sender); border-color: var(--sender); color: #fff; }
.tstep.done::before { background: var(--sender); }
.tstep.done em { color: var(--text); }
.tstep.cur i { border-color: var(--client); box-shadow: 0 0 0 4px #FFF1E6; }
.tstep.cur em { color: var(--client); font-weight: 600; }

.doc-acts { display: flex; gap: 6px; align-items: center; }
.ib {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--muted);
  border: 1px solid var(--border); background: #fff; cursor: pointer; padding: 0;
}
.ib svg { width: 16px; height: 16px; }
.ib:hover { color: var(--text); border-color: #CBD3DA; }
.ib.primary { background: var(--text); color: #fff; border-color: var(--text); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(43, 48, 56, .12);
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 7px; border: 0; background: none;
  font: inherit; font-size: .88rem; color: var(--text); text-decoration: none; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: #EEF2F5; }
.menu .danger { color: var(--danger); }
.empty.card { text-align: center; }

/* ---- Éditeur ---- */
.editor { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
.sidebar { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 16px; }
.steps { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-direction: column; gap: 4px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 6px 0; color: var(--muted); font-size: .9rem; }
.steps li .num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: #EAEEF2; font-size: .8rem; font-weight: 600; flex-shrink: 0;
}
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active .num { background: var(--primary); color: #fff; }
.steps li.done .num { background: var(--success); color: #fff; }

.role-tabs { display: flex; background: var(--text); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.role-tabs button {
  flex: 1; border: 0; background: transparent; color: #AEB8C2; font: 600 .86rem Inter, sans-serif;
  padding: 8px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.role-tabs button.active { background: var(--surface); color: var(--text); }

/* Liste des champs : une ligne par type, colorée selon la personne choisie */
.zone-tools { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.zone-btn {
  --c: var(--sender); --soft: var(--primary-soft);
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface);
  font: inherit; color: var(--text); cursor: pointer; transition: background .12s;
}
.zone-btn:last-child { border-bottom: 0; }
.zone-btn.client { --c: var(--client); --soft: #FFF1E6; }
.zone-btn:hover { background: #F8FAFC; }
.zone-btn.featured::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sender); }
.zone-btn.armed { background: var(--soft); }
.zone-btn .zi { flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--soft); color: var(--c); }
.zone-btn .zi svg { width: 16px; height: 16px; }
.zone-btn .zt { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.zone-btn .zt strong { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-btn .zt small { color: var(--muted); font-size: .76rem; }
.zone-btn .add {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--muted); transition: .12s;
}
.zone-btn .add svg { width: 14px; height: 14px; }
.zone-btn:hover .add { border-color: var(--c); color: var(--c); }
.zone-btn.armed .add { background: var(--c); border-color: var(--c); color: #fff; }

.place-hint { margin-top: 12px; padding: 8px 12px; border-radius: 8px; font-size: .82rem; background: var(--primary-soft); color: #14532D; }
#panel-draft[data-role=client] .place-hint { background: #FFF1E6; color: #9a3412; }

/* Barre d'avancement (vert uni) */
.zone-progress { margin: 14px 0; }
.zone-progress .bars { display: flex; gap: 6px; }
.zone-progress .bars span { flex: 1; height: 6px; border-radius: 3px; background: #EAEEF2; transition: background .2s; }
.zone-progress .bars span.ok { background: var(--sender); }
.bar-labels { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: .78rem; color: var(--muted); }
.bar-labels .ok { color: var(--sender); font-weight: 600; }
.btn-primary:disabled { background: #CBD3DA; border-color: #CBD3DA; color: #fff; opacity: 1; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.dot.sender { background: var(--sender); }
.dot.client { background: var(--client); }

.extra-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.extra-fields input:disabled { background: #F1F4F7; color: var(--muted); }
.mention-preview { font-family: 'Allura', cursive; font-size: 26px; color: #2B3038; min-height: 36px; margin-top: 4px; }


.pdf-viewer { display: flex; flex-direction: column; align-items: center; gap: 20px; min-width: 0; width: 100%; }
.pdf-page { position: relative; background: #fff; box-shadow: var(--shadow); max-width: 100%; }
.pdf-page canvas { display: block; }
.pdf-page .overlay { position: absolute; inset: 0; }
.pdf-viewer.placing .overlay { cursor: crosshair; }
/* Zoom : la page dépasse, on la fait défiler dans le visualiseur */
.pdf-viewer.zoomed { align-items: flex-start; overflow-x: auto; padding-top: 20px; margin-top: -20px; }

/* Barre du visualiseur (téléphone) : page courante + zoom */
.pdf-tools {
  position: fixed; right: 12px; bottom: 12px; z-index: 45; display: none; align-items: center; gap: 2px;
  padding: 4px; border-radius: 999px; background: var(--text); color: #fff;
  box-shadow: 0 6px 20px rgba(43, 48, 56, .25); font-variant-numeric: tabular-nums;
  transition: bottom .2s;
}
.pdf-tools .pt-page { padding: 0 10px 0 8px; font-size: .78rem; color: #AEB8C2; white-space: nowrap; }
.pdf-tools button {
  min-width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: #fff;
  font: 600 1.15rem Inter, sans-serif; cursor: pointer;
}
.pdf-tools button.pt-level { min-width: 58px; font-size: .78rem; background: rgba(255, 255, 255, .1); }
.pdf-tools button:active { background: rgba(255, 255, 255, .2); }
.sheet-handle { display: none; }
.page-label { position: absolute; top: -18px; left: 0; font-size: .75rem; color: var(--muted); }

.zone {
  position: absolute; border: 2px solid; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; user-select: none; touch-action: none;
}
.zone.sender { border-color: var(--sender); background: rgba(0, 184, 92, .12); color: var(--sender); }
.zone.client { border-color: var(--client); background: rgba(255, 106, 0, .12); color: var(--client); }
.zone.editable { cursor: move; }
.zone > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; max-width: 100%; }
.zone.type-block { align-items: stretch; justify-content: stretch; }
.block-preview { display: flex; flex-direction: column; width: 100%; padding: 4px 6px; font-size: 10px; font-weight: 500; overflow: hidden; }
.block-preview span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block-preview .cursive { font-family: 'Allura', cursive; font-size: 16px; }
.block-preview .sig { flex: 1; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; border-top: 1px dashed currentColor; margin-top: 2px; }
.zone.type-date, .zone.type-place, .zone.type-mention { font-size: 10px; border-width: 1.5px; justify-content: flex-start; }
.zone .del {
  position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: var(--danger); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
  display: none;
}
.zone .resize {
  position: absolute; right: -5px; bottom: -5px; width: 12px; height: 12px;
  background: currentColor; border-radius: 2px; cursor: nwse-resize; display: none;
}
.zone.editable:hover .del, .zone.editable:hover .resize, .zone.editable.selected .del, .zone.editable.selected .resize { display: block; }
.zone.pulse { animation: pulse 1.6s infinite; cursor: pointer; }
.zone.signed { background: transparent; border-style: dashed; }
.zone img { max-width: 100%; max-height: 100%; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 106, 0, .5); } 50% { box-shadow: 0 0 0 6px rgba(255, 106, 0, 0); } }

/* ---- Modale / pad de signature ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(43, 48, 56, .5); z-index: 100;
  display: grid; place-items: center; padding: 16px;
}
.modal { width: 100%; max-width: 560px; }
.modal-sm { max-width: 420px; }
.modal-sm h2 { margin-bottom: 6px; }
.modal-sm p { margin: 0; line-height: 1.5; }
.modal-sm p b { color: var(--text); }
.confirm-ico {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 14px;
  background: #FDECEC; color: var(--danger);
}
.confirm-ico svg { width: 22px; height: 22px; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #B91C1C; border-color: #B91C1C; }
.pad-wrap { border: 1px solid var(--border); border-radius: 8px; background: #fff; position: relative; margin-bottom: 12px; }
.pad-wrap canvas { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
.pad-wrap .baseline { position: absolute; left: 24px; right: 24px; bottom: 50px; border-bottom: 1px dashed #CBD3DA; pointer-events: none; }
.typed-preview {
  font-family: 'Allura', cursive; font-size: 52px; height: 200px;
  display: grid; place-items: center; color: #2B3038; overflow: hidden; white-space: nowrap;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.saved-sig { height: 200px; display: grid; place-items: center; padding: 16px; }
.saved-sig img { max-width: 100%; max-height: 100%; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .9rem; }
.checkbox input { margin-top: 4px; }

/* ---- Page client ---- */
.sign-banner { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 24px; }
.sign-banner-inner { max-width: 1100px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.success-screen { max-width: 520px; margin: 64px auto; text-align: center; }
.success-icon {
  width: 64px; height: 64px; border-radius: 50%; background: #e8f7ee; color: var(--success);
  display: grid; place-items: center; font-size: 32px; margin: 0 auto 16px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 200;
  font-size: .9rem; box-shadow: var(--shadow);
}

.draft-footer { display: flex; flex-direction: column; }
.mobile-cta { display: none; }

/* ================= Mobile ================= */
@media (max-width: 860px) {
  body { font-size: 15px; }
  .container { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .hide-sm { display: none !important; }
  h1 { font-size: 1.3rem; }
  .page-head { margin-bottom: 16px; gap: 10px; }
  .page-head h1 { word-break: break-word; }

  /* Dashboard */
  .page-head > .btn-primary { width: 100%; }
  .dropzone { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
  .stat { padding: 10px 12px; }
  .stat .muted { font-size: .72rem; line-height: 1.2; min-height: 2.4em; }
  .stat-value { font-size: 1.3rem; }
  .hello { flex-direction: column; align-items: stretch; }
  .todos { grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 20px; }
  /* Carte « À faire » mobile : une ligne de libellé, le titre sur 2 lignes, une flèche ronde */
  .todo { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px; }
  .todo .ti { width: 40px; height: 40px; border-radius: 12px; }
  .todo .tbody { min-width: 0; line-height: 1.3; }
  .todo b { display: inline; font-size: 1rem; }
  .todo .tl2 { display: inline; font-size: .92rem; }
  .todo.hot .tl2 { color: #fff; }
  .todo small {
    margin-top: 4px; font-size: .8rem; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .todo .tbtn { margin: 0; }
  .todo .tbtn-text { display: none; }
  .todo .tarr {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    background: #EEF2F5; color: var(--text); font-size: 1rem;
  }
  .todo.hot .tarr { background: #fff; color: #00A86B; }
  .todo.idle { padding: 10px 14px; }
  .todo.idle .ti { width: 32px; height: 32px; }
  .todo.idle b { font-size: .92rem; }
  .drop-hint { display: none; }
  .doc-row { grid-template-columns: minmax(0, 1fr) auto; gap: 14px 12px; }
  .doc-row .track { grid-column: 1 / -1; order: 3; }
  .doc-row .doc-acts { grid-row: 1; grid-column: 2; }
  .tstep em { font-size: .62rem; white-space: normal; }

  /* Éditeur : une seule colonne, l'historique après le PDF */
  .editor { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
  .sidebar { display: contents; }
  .steps-card { order: 0; padding: 12px 16px; }
  .sidebar > .card:not(.steps-card):not(.history-card) { order: 1; }
  .pdf-viewer { order: 2; }
  .history-card { order: 3; }
  .btn-download { padding: 6px 10px; font-size: .85rem; }

  /* Étapes en ligne : seule l'étape courante affiche son libellé */
  .steps { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
  .steps li { padding: 0; gap: 6px; }
  .steps li:not(:last-child)::after { content: ''; width: 14px; height: 1px; background: var(--border); }
  .steps li .lbl { display: none; }
  .steps li.active .lbl { display: inline; font-size: .85rem; }
  .steps li.active ~ li.active .lbl { display: none; }

  /* Outils de placement : panneau fixe en bas de l'écran */
  #panel-draft {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; order: 9;
    border-radius: 20px 20px 0 0; border: 0;
    padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 40px rgba(43, 48, 56, .12);
  }
  /* Poignée : un appui réduit le panneau pour voir le document en grand */
  .sheet-handle {
    display: block; position: absolute; top: 0; left: 50%; width: 64px; height: 22px; margin-left: -32px;
    border: 0; background: transparent; cursor: pointer; padding: 0;
  }
  .sheet-handle::before { content: ''; position: absolute; top: 7px; left: 14px; width: 36px; height: 4px; border-radius: 2px; background: #D3DAE1; }
  #panel-draft.min .role-tabs, #panel-draft.min .zone-tools, #panel-draft.min .place-hint { display: none; }
  #panel-draft.min .draft-footer { margin-top: 4px; padding-top: 0; border-top: 0; }
  body.has-sheet.sheet-min .container { padding-bottom: 110px; }

  /* Visualiseur : barre de zoom visible, pincement géré par l'appli */
  .pdf-tools:not([hidden]) { display: flex; }
  .pdf-viewer { touch-action: pan-x pan-y; }
  /* Pas de zoom du navigateur sur les éléments fixés (ils sortiraient de l'écran) */
  .pdf-tools, #panel-draft, .mobile-cta { touch-action: pan-x pan-y; }
  #panel-draft h2 { display: none; }

  /* Sélecteur Moi / Client : pastille de la couleur de la personne */
  .role-tabs { background: #EEF2F5; padding: 4px; border-radius: 12px; margin-bottom: 14px; }
  .role-tabs button { padding: 8px; font-size: .86rem; color: var(--muted); border-radius: 9px; transition: background .15s, color .15s; }
  .role-tabs button .dot { transition: background .15s; }
  .role-tabs button[data-role=sender].active { background: var(--sender); color: #fff; }
  .role-tabs button[data-role=client].active { background: var(--client); color: #fff; }
  .role-tabs button.active .dot { background: #fff; }

  /* Les 5 champs sur une ligne : icône ronde, nom dessous, sans cadre */
  .zone-tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; border: 0; border-radius: 0; background: transparent; overflow: visible; }
  .zone-btn, .zone-btn:last-child {
    flex-direction: column; justify-content: flex-start; gap: 6px; padding: 2px 0 4px; text-align: center;
    border: 0; border-radius: 12px; background: transparent; min-width: 0;
  }
  .zone-btn:hover, .zone-btn.armed { background: transparent; box-shadow: none; }
  .zone-btn .zi { width: 46px; height: 46px; border-radius: 50%; position: relative; transition: background .15s, color .15s, transform .15s; }
  .zone-btn .zi svg { width: 20px; height: 20px; }
  .zone-btn.armed .zi { background: var(--c); color: #fff; transform: scale(1.06); box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 35%, transparent); }
  .zone-btn .zt { align-items: center; width: 100%; }
  .zone-btn .zt strong { font-size: .7rem; font-weight: 500; line-height: 1.15; white-space: normal; overflow: visible; color: #475461; }
  .zone-btn.armed .zt strong { color: var(--c); font-weight: 700; }
  .zone-btn .zt small, .zone-btn .add { display: none; }
  /* Le bloc complet (conseillé) porte une petite étoile */
  .zone-btn.featured::before { content: none; }
  .zone-btn.featured .zi::after {
    content: '★'; position: absolute; top: -3px; right: -3px; width: 18px; height: 18px; border-radius: 50%;
    background: var(--sun); color: var(--text); font-size: 10px; line-height: 18px; text-align: center; border: 2px solid var(--surface);
  }

  .place-hint { margin: 10px 0 0; padding: 7px 12px; border-radius: 10px; text-align: center; }

  /* Avancement : deux pastilles + bouton */
  .draft-footer { flex-direction: row; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
  .draft-footer .zone-progress { margin: 0; flex: 1; min-width: 0; }
  .draft-footer .bars { display: none; }
  .draft-footer .bar-labels { margin: 0; justify-content: flex-start; gap: 6px; }
  .draft-footer .bar-labels > span {
    display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px;
    background: #EEF2F5; color: var(--muted); font-size: .76rem; font-weight: 600; white-space: nowrap;
  }
  .draft-footer .bar-labels > span::before { content: ''; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid #B9B5A8; }
  .draft-footer .bar-labels > span.ok { background: var(--primary-soft); color: var(--sender); }
  .draft-footer .bar-labels > span.ok::before { background: var(--sender); border-color: var(--sender); }
  .draft-footer .bar-labels .st-text { display: none; }
  .draft-footer .btn { width: auto; flex: 0 0 auto; padding: 11px 16px; border-radius: 12px; }
  body.has-sheet .container { padding-bottom: 260px; }

  /* Fenêtre de signature : plein écran défilable */
  .modal-backdrop { padding: 0; align-items: end; }
  .modal {
    max-width: none; max-height: 100dvh; overflow-y: auto;
    border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .extra-fields { grid-template-columns: 1fr; }
  .pad-wrap canvas, .typed-preview { height: 170px; }
  .modal-actions { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--surface); padding: 10px 0 0; margin-bottom: -4px; }
  .modal-actions .btn { flex: 1; }

  /* Page client : bouton de signature fixe en bas */
  .sign-banner { padding: 12px 16px; }
  .sign-banner #sign-btn { display: none; }
  .sign-banner .btn { padding: 6px 10px; font-size: .85rem; }
  .mobile-cta:not(.hidden) {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -8px 30px rgba(43, 48, 56, .1);
  }
  .mobile-cta .btn { padding: 14px; font-size: 1rem; }
  body:has(.mobile-cta:not(.hidden)) main { padding-bottom: 100px; }
  .success-screen { margin: 40px auto; padding: 0 16px; }

  .toast { bottom: auto; top: 16px; max-width: calc(100% - 32px); text-align: center; }
}

/* Écrans tactiles : poignées plus grandes */
@media (pointer: coarse) {
  .zone .resize { width: 22px; height: 22px; right: -11px; bottom: -11px; border-radius: 50%; border: 3px solid #fff; }
  .zone .del { width: 26px; height: 26px; top: -13px; right: -13px; font-size: 16px; }
  .zone.editable.selected { box-shadow: 0 0 0 3px rgba(0, 184, 92, .25); }
}

/* ---- Page client : photo de l'expéditeur ---- */
.from-row { display: flex; align-items: center; gap: 8px; }
.avatar-sm { width: 24px; height: 24px; font-size: .62rem; }

/* ---- Paramètres ---- */
.settings { max-width: 720px; display: grid; gap: 16px; }
.settings h1 { margin-bottom: 4px; }
.sec h2 { font-size: 1.05rem; margin: 0 0 2px; }
.sec .hint { color: var(--muted); font-size: .85rem; margin: 0 0 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.ph-row { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.ph-row .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-xl { width: 84px; height: 84px; font: 700 1.6rem 'Inter Tight', Inter, sans-serif; }
.sig-box { border: 1px dashed #CBD3DA; border-radius: 10px; background: #fff; height: 120px; display: grid; place-items: center; padding: 12px; }
.sig-box img { max-width: 100%; max-height: 100%; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
.saved { color: #166534; font-size: .85rem; font-weight: 600; margin-right: auto; }
.pw-meter { display: flex; gap: 4px; margin: -6px 0 14px; }
.pw-meter span { flex: 1; height: 5px; border-radius: 3px; background: #EAEEF2; transition: background .2s; }
.pw-meter span.on { background: var(--sender); }
@media (max-width: 860px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar .user-chip .who { display: none; }
  a.user-chip { padding: 0; }
}

/* Appareils connectés */
.devices { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.device { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.device.current { border-color: #BFE6CD; background: #F6FCF8; }
.dv-ico { width: 38px; height: 38px; border-radius: 10px; background: #EAEEF2; display: grid; place-items: center; flex-shrink: 0; color: var(--text); }
.dv-ico svg { width: 20px; height: 20px; }
.dv-text { flex: 1; min-width: 0; line-height: 1.35; }
.dv-text b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .92rem; }
.dv-text b .badge { font-size: .7rem; padding: 2px 8px; }
.dv-text small { display: block; color: var(--muted); font-size: .8rem; }
