:root {
  --ink: #16202d; --ink-2: #4a5566; --ink-3: #6b7585;
  --line: #e2e6ec; --line-2: #eef1f5; --bg: #f6f7f9; --card: #fff;
  --brand: #0f2a44; --brand-2: #1b3d5f;
  --accent: #0b7a5c; --accent-hover: #09654c; --accent-soft: #e5f4ef;
  --warn: #9a5b00; --warn-soft: #fdf3e2;
  --danger: #b42318; --danger-soft: #fdecea;
  --info: #1d4f91; --info-soft: #e8f0fb;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--info); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--s3); letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 var(--s4); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.muted { color: var(--ink-3); } .small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: var(--s3) var(--s4); display: flex; align-items: center; gap: var(--s4); min-height: 60px; }
.logo { color: #fff; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: var(--s2); font-size: 16px; }
.logo-mark { width: 28px; height: 28px; border-radius: 7px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.logo span.dim { font-weight: 400; opacity: .7; }
.topbar nav { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }
.topbar .link { color: rgba(255,255,255,.85); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; background: none; border: 0; cursor: pointer; font: inherit; }
.topbar .link:hover, .topbar .link:focus-visible { background: rgba(255,255,255,.1); color: #fff; }
.container { max-width: 1120px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); }
.container.narrow { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-start; justify-content: space-between; margin-bottom: var(--s5); }
.page-head h1 { margin: 0; }
.page-head .sub { margin-top: var(--s1); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s5); margin-bottom: var(--s5); }
.card > h2:first-child { margin-bottom: var(--s4); }
.card-flush { padding: 0; overflow: hidden; }
.grid-2 { display: grid; gap: var(--s5); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--bg); border-color: #cfd5dd; }
.btn:focus-visible, .input:focus-visible, .pdf-initial:focus-visible { outline: 3px solid rgba(29,79,145,.35); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #f3c3bd; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }

/* Forms */
.field { margin-bottom: var(--s4); }
.label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.input, .textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfd5dd; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .textarea:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px rgba(29,79,145,.15); }
.input.code { font-size: 26px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; max-width: 240px; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.check { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.row { display: grid; gap: var(--s3); }
@media (min-width: 640px) { .row-3 { grid-template-columns: 1.2fr 1.4fr 1fr; } }

.dropzone { display: block; border: 2px dashed #cfd5dd; border-radius: var(--radius); padding: var(--s6) var(--s4); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; background: #fbfcfd; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone strong { display: block; font-size: 16px; margin: var(--s2) 0 4px; }
.dropzone.has-file { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }

.signer-row { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); margin-bottom: var(--s3); position: relative; background: #fbfcfd; }
.signer-row .num { position: absolute; top: -10px; left: 12px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 9px; }
.signer-row .remove { position: absolute; top: 6px; right: 6px; }

/* Alerts & badges */
.alert { padding: var(--s3) var(--s4); border-radius: 8px; margin-bottom: var(--s4); font-size: 14px; border: 1px solid; }
.alert-success { background: var(--accent-soft); border-color: #b9e2d4; color: #075a44; }
.alert-error { background: var(--danger-soft); border-color: #f3c3bd; color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: #c6d8f3; color: var(--info); }
.alert-warn { background: var(--warn-soft); border-color: #f1d9ab; color: var(--warn); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { background: #eef1f5; color: #4a5566; }
.badge-sent, .badge-invited { background: var(--warn-soft); color: var(--warn); }
.badge-completed, .badge-signed { background: var(--accent-soft); color: var(--accent); }
.badge-declined, .badge-cancelled, .badge-expired { background: var(--danger-soft); color: var(--danger); }
.badge-waiting { background: #eef1f5; color: var(--ink-3); }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); margin-bottom: var(--s5); }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: border-color .15s; }
.stat:hover, .stat.is-active { border-color: var(--brand-2); }
.stat .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; display: block; }
.stat .l { font-size: 13px; color: var(--ink-3); }
.toolbar { display: flex; gap: var(--s2); margin-bottom: var(--s4); }
.toolbar .input { flex: 1; }
.list-item { display: flex; gap: var(--s4); align-items: center; padding: var(--s4) var(--s5); border-top: 1px solid var(--line-2); text-decoration: none; color: inherit; transition: background .15s; }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: #fafbfc; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
@media (max-width: 560px) { .list-item { flex-wrap: wrap; padding: var(--s4); } .list-item .side { flex-direction: row; width: 100%; justify-content: space-between; align-items: center; } }
.empty { text-align: center; padding: var(--s7) var(--s4); }
.progress { display: flex; gap: 3px; }
.progress i { width: 16px; height: 5px; border-radius: 3px; background: var(--line); }
.progress i.on { background: var(--accent); }
.pagination { display: flex; gap: var(--s2); justify-content: center; margin-top: var(--s4); }

/* Contract detail */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line-2); }
.steps li:first-child { border-top: 0; padding-top: 0; }
.steps .dot { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--line-2); color: var(--ink-3); }
.steps .dot.signed { background: var(--accent); color: #fff; }
.steps .dot.invited { background: var(--warn-soft); color: var(--warn); }
.steps .dot.declined { background: var(--danger); color: #fff; }
.steps .who { flex: 1; min-width: 0; }
.steps .badge { align-self: flex-start; }
.steps .who .meta { font-size: 13px; color: var(--ink-3); word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { display: grid; grid-template-columns: 112px 1fr; gap: var(--s3); padding: 8px 0; border-top: 1px solid var(--line-2); }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.timeline .ip { color: var(--ink-3); font-size: 12px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s4); margin: 0; font-size: 13px; }
dl.kv dt { color: var(--ink-3); } dl.kv dd { margin: 0; min-width: 0; }
.downloads { display: grid; gap: var(--s2); }

/* Signing */
.sign-top { background: #fff; border-bottom: 1px solid var(--line); }
.sign-top .topbar-inner { min-height: 56px; }
.sign-top .logo { color: var(--brand); }
.sign-top .logo-mark { background: var(--brand); color: #fff; }
.secure { margin-left: auto; font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.center-card { max-width: 460px; margin: var(--s6) auto; }
.doc-wrap { max-width: 900px; margin: 0 auto; padding: var(--s4) var(--s3) 140px; }
.doc-intro { margin-bottom: var(--s4); }
.pdf-page { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(16,24,40,.12); margin: 0 auto var(--s5); border-radius: 2px; }
.pdf-page canvas { display: block; width: 100%; height: auto; }
.pdf-page .page-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3); background: #f9fafb; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pdf-page .page-no { font-size: 13px; color: var(--ink-3); }
.pdf-initial { display: inline-flex; align-items: center; gap: var(--s2); }
.pdf-initial img { height: 28px; }
.pdf-page.is-done .page-bar { background: var(--accent-soft); }
.page-placeholder { aspect-ratio: 210/297; display: grid; place-items: center; color: var(--ink-3); }
.dock { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(16,24,40,.08); z-index: 10; }
.dock-inner { max-width: 900px; margin: 0 auto; padding: var(--s3) var(--s4); display: flex; align-items: center; gap: var(--s4); }
.dock .count { font-size: 14px; flex: 1; min-width: 0; }
.dock .bar { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.dock .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.55); display: none; align-items: flex-end; justify-content: center; z-index: 20; padding: 0; }
.modal.open { display: flex; }
@media (min-width: 640px) { .modal { align-items: center; padding: var(--s4); } }
.modal-box { background: #fff; width: 100%; max-width: 560px; border-radius: 14px 14px 0 0; padding: var(--s5); max-height: 92vh; overflow-y: auto; }
@media (min-width: 640px) { .modal-box { border-radius: 14px; } }
.pad { position: relative; border: 1px solid #cfd5dd; border-radius: 8px; background: #fff; touch-action: none; }
.pad canvas { display: block; width: 100%; cursor: crosshair; }
.pad .baseline { position: absolute; left: 6%; right: 6%; bottom: 26%; border-bottom: 1px dashed #c3cad4; pointer-events: none; }
.pad .clear { position: absolute; top: 6px; right: 6px; }
.pad.small canvas { height: 130px; } .pad.large canvas { height: 190px; }
.consent { background: var(--bg); border-radius: 8px; padding: var(--s3) var(--s4); font-size: 14px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 560px) {
  .logo span.dim, .topbar .link.wide { display: none; }
  .topbar-inner { gap: var(--s2); }
  .page-head .btn-lg { width: 100%; }
  .secure span { display: none; }
}

/* Tweestapsverificatie */
.setup-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.setup-steps > li { position: relative; padding: 0 0 var(--s5) 44px; counter-increment: step; }
.setup-steps > li:last-child { padding-bottom: 0; }
.setup-steps > li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.setup-steps h2 { font-size: 16px; margin-bottom: var(--s2); }
.qr { width: 196px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: var(--s3); }
.qr svg { display: block; width: 100%; height: auto; }
code.secret { font-size: 14px; letter-spacing: .04em; }
.recovery-codes { list-style: none; padding: var(--s4); margin: 0 0 var(--s4); background: var(--bg); border-radius: 8px; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2) var(--s4); }
.recovery-codes code { font-size: 15px; }
@media (max-width: 400px) { .recovery-codes { grid-template-columns: 1fr; } }

/* Zoomen bij ondertekenen */
.page-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.page-canvas { width: calc(100% * var(--zoom, 1)); }
.page-canvas canvas, .page-canvas .page-placeholder { display: block; width: 100%; height: auto; }
.zoom { display: flex; align-items: center; gap: 4px; flex: none; }
.zoom .btn { min-width: 40px; min-height: 40px; padding: 0; font-size: 18px; }
.zoom span { min-width: 44px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
@media (max-width: 480px) {
  .dock-inner { flex-wrap: wrap; gap: var(--s2) var(--s3); }
  .dock .count { flex: 1 1 0; font-size: 13px; }
  .dock #dock-action { flex: 1 1 100%; min-height: 46px; }
}

/* Handtekeningvelden */
.page-canvas { position: relative; }
.fields-toolbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); }
.signer-chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px; border: 2px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600; transition: border-color .15s, background .15s; }
.chip span i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.chip span b { font-weight: 600; font-size: 12px; color: var(--ink-3); background: var(--line-2); border-radius: 999px; padding: 0 7px; }
.chip input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, #fff); }
.chip input:focus-visible + span { outline: 3px solid rgba(29,79,145,.35); outline-offset: 2px; }
.field-pages { max-width: 860px; margin: 0 auto; }
.field-pages .page-canvas { cursor: copy; }
.sig-field { position: absolute; border: 2px dashed var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); border-radius: 4px; cursor: move; touch-action: none; user-select: none; display: flex; align-items: flex-end; }
.sig-field.is-active { border-style: solid; box-shadow: 0 2px 10px rgba(16,24,40,.2); }
.sig-label { font-size: 11px; font-weight: 600; color: var(--c); padding: 2px 6px; background: rgba(255,255,255,.85); border-radius: 0 3px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sig-remove { position: absolute; top: -12px; right: -12px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--c); color: #fff; font-size: 12px; cursor: pointer; display: grid; place-items: center; }
.sig-resize { position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 3px; background: var(--c); cursor: nwse-resize; }
/* In het ondertekenscherm */
.sig-spot { position: absolute; border: 2px dashed var(--accent); background: rgba(11,122,92,.08); border-radius: 4px; display: flex; align-items: flex-end; pointer-events: none; }
.sig-spot span { font-size: 11px; font-weight: 700; color: var(--accent); background: rgba(255,255,255,.9); padding: 2px 6px; border-radius: 0 3px 0 0; }
.sig-spot.other { border-color: #c3cad4; background: rgba(195,202,212,.12); }
.sig-spot.other span { color: var(--ink-3); font-weight: 600; }
