:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1a2230;
  --muted: #6b7488;
  --line: #e3e8f0;
  --brand: #2b5ce6;
  --brand-dark: #1e46b8;
  --green: #1a9d5a;
  --amber: #d98a00;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.06), 0 8px 30px rgba(20, 30, 60, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .4em; }
button { font: inherit; cursor: pointer; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand span { color: var(--brand); }

.container { max-width: 1080px; margin: 24px auto; padding: 0 20px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}

label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 15px; background: #fbfcfe;
}
input:focus { outline: 2px solid rgba(43, 92, 230, .25); border-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; border: none;
  padding: 11px 18px; border-radius: 9px; font-weight: 600;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #eef1f7; color: var(--ink); }
.btn.secondary:hover { background: #e2e7f1; }
.btn.ghost { background: transparent; color: var(--brand); padding: 6px 10px; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  background: transparent; border: none; padding: 9px 16px; border-radius: 8px;
  font-weight: 600; color: var(--muted);
}
.tab.active { background: var(--brand); color: #fff; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.badge.sent { background: #eef1f7; color: var(--muted); }
.badge.viewed { background: #fff3dc; color: var(--amber); }
.badge.signed { background: #e2f6ec; color: var(--green); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.hint { color: var(--muted); font-size: 13px; }
.error { color: #c0392b; font-size: 14px; margin-top: 10px; }
.ok { color: var(--green); font-size: 14px; margin-top: 10px; }

/* Zone d'édition PDF */
.pdf-stage { background: #5b6072; border-radius: 10px; padding: 16px; max-height: 70vh; overflow: auto; }
.pdf-page { position: relative; margin: 0 auto 16px; box-shadow: 0 4px 20px rgba(0,0,0,.3); background:#fff; }
.pdf-page canvas { display: block; }
.sig-field {
  position: absolute; border: 2px dashed var(--brand);
  background: rgba(43, 92, 230, .12); cursor: move;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-dark); font-size: 12px; font-weight: 700; user-select: none;
}
.sig-field .del {
  position: absolute; top: -10px; right: -10px; width: 22px; height: 22px;
  border-radius: 50%; background: #c0392b; color: #fff; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1;
}
.sig-field .resize {
  position: absolute; bottom: -6px; right: -6px; width: 14px; height: 14px;
  background: var(--brand); border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize;
}

/* Page de signature */
.sign-wrap { max-width: 900px; margin: 0 auto; padding: 20px; }
.sig-pad-box { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.sig-pad-box canvas { width: 100%; height: 180px; touch-action: none; display: block; border-radius: 10px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.spacer { height: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
