/* LendSign design system — same family as lendframe.ca */

/* ── Tokens ───────────────────────────────────────────── */
:root {
  --navy: #2b2b2b;
  --navy-deep: #1e1e1e;
  --gold: #c9a227;
  --gold-light: #d4af37;
  --gold-dark: #8a6d15;
  --gold-rgb: 201, 162, 39;
  --on-dark: #fff;
  --on-gold: #1e1e1e;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #d1d5db;
  --gray-500: #9ca3af;
  --gray-600: #6b7280;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --off-white: #f9fafb;
  --white: #fff;
  --success: #16a34a;
  --danger: #dc2626;
  --blue: #2563eb;
  --teal: #0d9488;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --font-heading: 'Montserrat', sans-serif;
  --font-body: 'Inter', sans-serif;
  --focus-ring: 0 0 0 3px rgba(var(--gold-rgb), 0.25);
}

/* ── Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--off-white);
  color: var(--gray-900);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; margin: 0 0 .5em; color: var(--navy-deep); line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 .75em; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }
.muted { color: var(--gray-600); }
.text-danger { color: var(--danger); }
.small { font-size: .85rem; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ── Layout ───────────────────────────────────────────── */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.container--narrow { max-width: 520px; }
.container--medium { max-width: 760px; }
.container--form { max-width: 860px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ── Navbar ───────────────────────────────────────────── */
.navbar { background: var(--navy-deep); height: 56px; display: flex; align-items: center; padding: 0 16px; gap: 24px; position: sticky; top: 0; z-index: 50; }
.logo { font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem; color: var(--on-dark); letter-spacing: .01em; }
.logo:hover { text-decoration: none; }
.logo__accent { color: var(--gold); }
.nav-links { display: flex; gap: 20px; flex: 1; }
.nav-links a { color: var(--on-dark); opacity: .85; font-size: .9rem; font-weight: 500; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav-links a:hover, .nav-links a.active { opacity: 1; color: var(--gold); text-decoration: none; border-bottom-color: var(--gold); }
.nav-user { display: flex; gap: 14px; align-items: center; color: var(--on-dark); font-size: .88rem; }
.nav-user form { margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--on-dark); opacity: .85; font: inherit; cursor: pointer; }
.link-button:hover { color: var(--gold); opacity: 1; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-heading); font-weight: 600; font-size: .9rem;
  padding: 9px 18px; border-radius: var(--radius); border: 2px solid transparent;
  cursor: pointer; background: transparent; color: var(--navy); text-decoration: none; line-height: 1.2;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn-primary:hover:not([disabled]) { background: var(--gold-light); border-color: var(--gold-light); color: var(--on-gold); }
.btn-outline { border-color: var(--navy); color: var(--navy); background: var(--white); }
.btn-outline:hover:not([disabled]) { background: var(--navy); color: var(--white); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--white); }
.btn-danger:hover:not([disabled]) { background: var(--danger); color: var(--white); }
.btn-ghost { color: var(--gray-600); }
.btn-ghost:hover { color: var(--navy-deep); background: var(--gray-200); }
.btn-sm { padding: 5px 12px; font-size: .8rem; border-radius: 6px; }
.btn-block { display: flex; width: 100%; }

/* ── Cards ────────────────────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; }
.card--accent { border-top: 3px solid var(--gold); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.card + .card { margin-top: 16px; }
.empty { text-align: center; padding: 48px 20px; }
.empty h2 { margin-bottom: 8px; }

/* ── Chips ────────────────────────────────────────────── */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--gray-200); color: var(--gray-800); white-space: nowrap; }
.chip--created, .chip--draft { background: var(--gray-200); color: var(--gray-600); }
.chip--sent { background: rgba(37, 99, 235, .12); color: #1d4ed8; }
.chip--delivered { background: rgba(13, 148, 136, .13); color: #0f766e; }
.chip--completed { background: rgba(22, 163, 74, .13); color: #15803d; }
.chip--declined { background: rgba(220, 38, 38, .12); color: #b91c1c; }
.chip--voided { background: var(--gray-200); color: var(--gray-600); text-decoration: line-through; }
.chip--warn { background: rgba(var(--gold-rgb), .18); color: var(--gold-dark); }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-chip { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--gray-300); background: var(--white); color: var(--gray-800); font-size: .85rem; font-weight: 500; }
.filter-chip:hover { border-color: var(--gold); text-decoration: none; }
.filter-chip.active { background: var(--navy-deep); border-color: var(--navy-deep); color: var(--white); }

/* ── Tables ───────────────────────────────────────────── */
.table-wrap { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-600); padding: 10px 14px; background: var(--gray-100); border-bottom: 1px solid var(--gray-200); }
.table td { padding: 9px 14px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
.table tbody tr:nth-child(even) { background: var(--off-white); }
.table tbody tr:hover { background: rgba(var(--gold-rgb), .07); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table .num { text-align: right; }
.table-plain { box-shadow: none; }

/* ── Forms ────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
label, .label { display: block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-600); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=file], textarea, select {
  width: 100%; font: inherit; color: var(--gray-900); background: var(--white);
  border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 9px 12px;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: var(--focus-ring); }
.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; text-transform: none; letter-spacing: 0; color: var(--gray-800); font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--gold-dark); }
.hint { font-size: .8rem; color: var(--gray-600); margin-top: 4px; }
.field-error { color: var(--danger); font-size: .82rem; margin-top: 4px; }
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input { max-width: 340px; }
input.is-invalid, textarea.is-invalid, select.is-invalid { border-color: var(--danger); }
input.is-invalid:focus, textarea.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }
.label__opt { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--gray-500); margin-left: 4px; }
.section-head { display: flex; gap: 12px; align-items: flex-start; }
.section-head h2 { margin-bottom: 2px; }
.step-no { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--navy-deep); color: var(--gold); font-family: var(--font-heading); font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; align-items: center; position: sticky; bottom: 0; background: var(--off-white); padding: 12px 0; border-top: 1px solid var(--gray-200); }
.form-actions--static { position: static; background: transparent; border-top: 0; padding-top: 4px; }
.recipient-row { display: grid; grid-template-columns: 1.2fr 1.6fr 64px 110px 96px 32px; gap: 10px; align-items: start; padding: 12px; margin-bottom: 8px; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: var(--radius); }
.recipient-row .field { margin: 0; min-width: 0; }
.recipient-row label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipient-row .remove-recipient { height: 40px; margin-top: 19px; }
.recipient-row .field-error { font-size: .76rem; }

/* ── Templates: role rows, role chips, picker ─────────── */
.recipient-row--role { grid-template-columns: 1.6fr 96px 140px 32px; }
.recipient-row--use { grid-template-columns: 150px 1.2fr 1.6fr 110px; }
.recipient-row--use .role-cell { padding-top: 22px; min-width: 0; }
.recipient-row--use .role-cell .small { display: block; margin-top: 4px; }
.role-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 3px 11px 3px 9px; border-radius: 999px; background: var(--white); border: 1px solid var(--gray-300); font-size: .82rem; font-weight: 600; color: var(--gray-900); }
.role-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch-0 { background: #2563eb; }
.swatch-1 { background: #16a34a; }
.swatch-2 { background: #9333ea; }
.swatch-3 { background: #ea580c; }
.swatch-4 { background: #0d9488; }
.swatch-5 { background: #e11d48; }
.template-pick { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; padding: 14px 20px; }
.template-pick h2 { margin: 0; font-size: 1rem; }
.template-pick__form { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 260px; margin: 0; }
.template-pick__form select { flex: 1; min-width: 0; }
.template-pick .muted { margin: 0; font-size: .85rem; }
.table td .subline { display: block; font-size: .8rem; color: var(--gray-600); font-weight: 400; margin-top: 1px; }
.page-head__meta { margin: 4px 0 0; }
/* Drop zone */
.dropzone { position: relative; border: 2px dashed var(--gray-300); border-radius: var(--radius-lg); background: var(--gray-100); padding: 28px 16px; text-align: center; color: var(--gray-600); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--gold); background: rgba(var(--gold-rgb), .06); outline: none; }
.dropzone.is-over { border-color: var(--gold-dark); background: rgba(var(--gold-rgb), .12); border-style: solid; }
.dropzone.is-invalid { border-color: var(--danger); }
.dropzone__input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; }
.dropzone__icon { color: var(--gold-dark); margin-bottom: 6px; }
.dropzone__title { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; color: var(--navy-deep); margin: 0 0 2px; }
.dropzone__browse { color: var(--gold-dark); text-decoration: underline; }
.dropzone__hint { font-size: .8rem; margin: 0; }
.file-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list[hidden] { display: none; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--white); }
.file-item--bad { border-color: #fecaca; background: #fef2f2; }
.file-item--bad .file-item__meta { color: var(--danger); font-weight: 600; }
.file-item__num { width: 22px; height: 22px; border-radius: 50%; background: var(--navy-deep); color: var(--gold); font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.file-item__icon { font-size: .62rem; font-weight: 700; letter-spacing: .05em; color: var(--white); background: var(--danger); border-radius: 4px; padding: 3px 5px; flex: none; }
.file-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-item__name { font-weight: 500; font-size: .9rem; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item__meta { font-size: .76rem; color: var(--gray-600); }
.file-item__btns { display: flex; gap: 2px; flex: none; }
.icon-btn { border: 1px solid transparent; background: transparent; color: var(--gray-600); cursor: pointer; font-size: .95rem; line-height: 1; width: 28px; height: 28px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover:not([disabled]) { background: var(--gray-200); color: var(--navy-deep); }
.icon-btn[disabled] { opacity: .3; cursor: default; }

/* ── Flash ────────────────────────────────────────────── */
.flashes { max-width: 1100px; margin: 12px auto 0; padding: 0 16px; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; border: 1px solid; font-size: .9rem; display: flex; justify-content: space-between; gap: 12px; }
.flash--info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.flash--success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash--error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash--warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash__close { background: none; border: 0; cursor: pointer; color: inherit; font-size: 1.1rem; line-height: 1; }

/* ── Detail page ──────────────────────────────────────── */
.timeline { display: flex; gap: 0; margin: 4px 0 8px; }
.timeline__step { flex: 1; position: relative; padding-top: 22px; text-align: center; font-size: .82rem; color: var(--gray-500); }
.timeline__step::before { content: ''; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: var(--gray-300); }
.timeline__step::after { content: ''; position: absolute; top: 0; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--white); border: 2px solid var(--gray-300); }
.timeline__step:first-child::before { left: 50%; }
.timeline__step:last-child::before { right: 50%; }
.timeline__step.done { color: var(--gray-900); }
.timeline__step.done::before { background: var(--gold); }
.timeline__step.done::after { background: var(--gold); border-color: var(--gold); }
.timeline__step.bad::after { background: var(--danger); border-color: var(--danger); }
.timeline__label { font-weight: 600; display: block; }
.badge-ok { color: var(--success); font-weight: 600; }
.badge-bad { color: var(--danger); font-weight: 700; }
.lock-badge { font-size: .72rem; background: var(--gray-200); color: var(--gray-800); padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
.lock-badge--locked { background: rgba(220, 38, 38, .12); color: #b91c1c; }
details.confirm { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 10px 14px; background: var(--white); }
details.confirm > summary { cursor: pointer; font-weight: 600; color: var(--danger); font-family: var(--font-heading); font-size: .9rem; }
details.confirm[open] > summary { margin-bottom: 10px; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--gray-200); flex-wrap: wrap; }
.doc-list li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--gray-600); }
.kv dd { margin: 0; word-break: break-all; }

/* ── Auth ─────────────────────────────────────────────── */
.auth-wrap { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { color: var(--navy-deep); font-size: 1.6rem; display: block; text-align: center; margin-bottom: 16px; }

/* ── Editor ───────────────────────────────────────────── */
body.editor-body { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
.editor-top { background: var(--navy-deep); color: var(--on-dark); height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 16px; flex: none; }
.editor-top .subject { flex: 1; font-family: var(--font-heading); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-top .back { color: var(--on-dark); opacity: .8; font-size: .88rem; }
.save-status { font-size: .82rem; color: var(--on-dark); opacity: .8; min-width: 90px; text-align: right; }
.save-status.is-error { color: #fca5a5; }
.editor-banner { background: var(--danger); color: var(--white); padding: 8px 16px; text-align: center; font-weight: 500; flex: none; }
.editor-banner--warn { background: var(--gold); color: var(--navy-deep); }
.editor-layout { flex: 1; display: grid; grid-template-columns: 220px 1fr 280px; min-height: 0; }
.editor-docs, .editor-palette { background: var(--white); overflow-y: auto; padding: 16px; }
.editor-docs { border-right: 1px solid var(--gray-200); }
.editor-palette { border-left: 1px solid var(--gray-200); }
.editor-canvas { overflow: auto; padding: 24px 16px 80px; background: var(--gray-200); touch-action: pan-y pinch-zoom; position: relative; }
.editor-docs h3, .editor-palette h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-600); margin: 0 0 8px; font-family: var(--font-body); font-weight: 600; }
.palette-section { margin-bottom: 20px; }
.doc-nav { list-style: none; margin: 0; padding: 0; }
.doc-item { display: flex; align-items: center; gap: 6px; padding: 6px 4px 6px 2px; border-radius: 6px; border: 1px solid transparent; }
.doc-item:hover { background: var(--gray-100); }
.doc-item[draggable=true] { cursor: grab; }
.doc-item.is-dragging { opacity: .4; }
.doc-item.is-over { border-color: var(--gold); background: rgba(var(--gold-rgb), .1); }
.doc-item__grip { color: var(--gray-500); font-size: .8rem; letter-spacing: -3px; flex: none; }
.doc-item__num { width: 18px; height: 18px; border-radius: 50%; background: var(--navy-deep); color: var(--gold); font-size: .66rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.doc-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-item__name { color: var(--gray-800); font-size: .84rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-item__name:hover { text-decoration: none; color: var(--gold-dark); }
.doc-item__pages { font-size: .7rem; color: var(--gray-600); }
.doc-item__btns { display: flex; flex-direction: column; flex: none; }
.doc-item__btn { border: 0; background: transparent; color: var(--gray-600); cursor: pointer; font-size: .72rem; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.doc-item__btn:hover:not([disabled]) { background: var(--gray-200); color: var(--navy-deep); }
.doc-item__btn[disabled] { opacity: .3; cursor: default; }
.doc-nav .hint { margin: 10px 0 12px; font-size: .74rem; }
.doc-item__remove { border: 0; background: transparent; color: var(--gray-500); cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 5px; border-radius: 4px; flex: none; }
.doc-item__remove:hover:not([disabled]) { background: rgba(220, 38, 38, .1); color: var(--danger); }
.editor-docs { position: relative; }
.editor-docs.is-over { outline: 2px dashed var(--gold); outline-offset: -6px; background: rgba(var(--gold-rgb), .06); }
.doc-drop-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; font-family: var(--font-heading); font-weight: 600; color: var(--gold-dark); pointer-events: none; }
.editor-docs .hint { font-size: .74rem; margin-top: 8px; }
.size-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; }
.size-grid__cell { display: flex; align-items: center; gap: 4px; }
.size-grid__k { font-size: .7rem; font-weight: 600; color: var(--gray-600); }
.size-grid input[type=number] { padding: 6px 6px; }
.recipient-option { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: .88rem; text-transform: none; letter-spacing: 0; color: var(--gray-900); font-weight: 500; margin: 0; }
.recipient-option:hover { background: var(--gray-100); }
.recipient-option input { accent-color: var(--gold-dark); }
.recipient-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.tab-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette-tab { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; padding: 9px 8px; border: 1px solid var(--gray-300); border-radius: var(--radius); background: var(--white); font-size: .82rem; font-weight: 500; font-family: var(--font-body); color: var(--gray-900); display: flex; align-items: center; gap: 6px; }
.palette-tab:hover { border-color: var(--gold); }
.palette-tab__icon { font-weight: 700; color: var(--gold-dark); width: 16px; text-align: center; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; border: 1.5px dashed var(--gold-dark); background: rgba(var(--gold-rgb), .2); border-radius: 3px; transform: translate(-50%, -50%); }
.anchored-list { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.anchored-list li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--gray-200); }
.props { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 12px; background: var(--gray-100); }
.props .field { margin-bottom: 10px; }
.page-stack { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.page-doc-title { align-self: flex-start; font-family: var(--font-heading); font-weight: 600; color: var(--gray-800); margin: 8px auto 0; width: 100%; max-width: 900px; font-size: .9rem; }
.page { position: relative; width: 100%; max-width: 900px; background: var(--white); box-shadow: 0 2px 12px rgba(0, 0, 0, .15); user-select: none; -webkit-user-select: none; }
.page > img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.page-num { position: absolute; bottom: -1.4em; right: 0; font-size: .7rem; color: var(--gray-600); }

/* Tabs (editor + signer) */
.tab { position: absolute; border: 1.5px solid; border-radius: 3px; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: move; font-family: var(--font-body); font-weight: 600; color: var(--gray-900); line-height: 1; }
.tab.selected { outline: 2px solid var(--gold); outline-offset: 1px; z-index: 5; }
.tab__label { pointer-events: none; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; min-width: 0; max-width: 100%; }
.tab__caption { position: absolute; left: 2px; bottom: 0; font-size: 8px; font-weight: 500; opacity: .85; pointer-events: none; line-height: 1.1; }
.tab__req { position: absolute; top: 0; right: 2px; color: var(--danger); font-size: 11px; pointer-events: none; }
.tab__handle { position: absolute; right: -7px; bottom: -7px; width: 16px; height: 16px; background: var(--gold); border: 2px solid var(--white); border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); cursor: nwse-resize; touch-action: none; display: none; z-index: 1; }
.tab.selected { overflow: visible; }
.tab.selected .tab__handle { display: block; }
.tab.locked { cursor: default; }

/* ── Signer ───────────────────────────────────────────── */
body.signer-body { background: var(--gray-200); }
.signer-top { background: var(--navy-deep); color: var(--on-dark); min-height: 56px; display: flex; align-items: center; gap: 14px; padding: 8px 16px; position: sticky; top: 0; z-index: 60; flex-wrap: wrap; }
.signer-top .who { color: var(--on-dark); opacity: .85; font-size: .85rem; flex: 1; min-width: 120px; }
.signer-progress { font-size: .85rem; color: var(--on-dark); display: flex; align-items: center; gap: 10px; min-width: 180px; }
.signer-progress .pbar { flex: 1; min-width: 80px; }
.signer-canvas { padding: 20px 8px 100px; }
.signer-canvas.is-locked .sfield { cursor: not-allowed; opacity: .55; }
.signer-canvas.is-locked .sfield input { pointer-events: none; }
.consent-bar { position: sticky; top: 56px; z-index: 55; background: rgba(var(--gold-rgb), .10); border-bottom: 1px solid var(--gold); padding: 8px 16px; font-size: .9rem; color: var(--gray-900); }
.consent-bar__row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; max-width: 1100px; margin: 0 auto; }
.consent-bar__lead { font-weight: 600; color: var(--navy-deep); }
.consent-bar__check { margin: 0; flex: 1; min-width: 240px; }
.consent-bar__more { font-size: .85rem; color: var(--gold-dark); text-decoration: underline; }
.consent-bar__more:hover { color: var(--navy-deep); }
.consent-bar__disclosure { max-width: 1100px; margin: 10px auto 2px; padding: 12px 14px; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: .88rem; max-height: 40vh; overflow-y: auto; }
.consent-bar__disclosure h3 { margin-top: 0; }
.consent-bar.is-shaking { animation: shake .35s ease-in-out 1; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.sfield { position: absolute; border: 1.5px dashed; border-radius: 3px; background-color: rgba(var(--gold-rgb), .18); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--gray-900); overflow: hidden; padding: 0; font-family: var(--font-body); }
.sfield:focus-visible { outline: 2px solid var(--gold-dark); outline-offset: 2px; }
.sfield.done { border-style: solid; background-color: rgba(22, 163, 74, .08); border-color: var(--success) !important; }
.sfield.invalid { border-color: var(--danger) !important; background-color: rgba(220, 38, 38, .12); }
.sfield img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.sfield__clear { position: absolute; top: 0; right: 0; background: rgba(0, 0, 0, .55); color: #fff; border: 0; font-size: 11px; line-height: 1; padding: 2px 4px; cursor: pointer; border-radius: 0 0 0 4px; }
.sfield--input { padding: 0; cursor: text; }
.sfield--input input[type=text] { width: 100%; height: 100%; border: 0; background: transparent; padding: 0 4px; font-family: Helvetica, Arial, sans-serif; border-radius: 0; box-shadow: none; }
.sfield--input input[type=checkbox] { width: 70%; height: 70%; accent-color: var(--gold-dark); }
.sfield--static { cursor: default; border-style: solid; background-color: rgba(0, 0, 0, .04); border-color: var(--gray-300) !important; font-weight: 500; }
.overlay { position: absolute; pointer-events: none; display: flex; align-items: center; overflow: hidden; font-family: Helvetica, Arial, sans-serif; }
.overlay img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pulse { animation: pulse 1.1s ease-out 1; }
.next-tag { position: fixed; z-index: 58; background: var(--gold); color: var(--navy-deep); border: 0; border-radius: 4px; padding: 10px 14px 10px 16px; font-family: var(--font-heading); font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; box-shadow: 0 3px 10px rgba(0, 0, 0, .28); white-space: nowrap; transition: top .2s ease, left .2s ease, background .15s; }
.next-tag:hover { background: var(--gold-light); }
.next-tag::before { content: ''; position: absolute; left: -9px; top: 50%; transform: translateY(-50%); border: 9px solid transparent; border-left: 0; border-right-color: var(--gold); }
.next-tag:hover::before { border-right-color: var(--gold-light); }
.next-tag--above::before { left: 14px; top: -9px; transform: none; border: 9px solid transparent; border-top: 0; border-bottom-color: var(--gold); }
.next-tag--below::before { left: 14px; top: auto; bottom: -9px; transform: none; border: 9px solid transparent; border-bottom: 0; border-top-color: var(--gold); }
.next-tag--finish { background: var(--success); color: var(--white); }
.next-tag--finish::before { border-right-color: var(--success); }
.next-tag--finish.next-tag--above::before { border-bottom-color: var(--success); }
.next-tag--finish.next-tag--below::before { border-top-color: var(--success); }
.next-tag--finish:hover { background: #15803d; }
.next-tag--finish:hover::before { border-right-color: #15803d; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--gold-rgb), .9); } 100% { box-shadow: 0 0 0 16px rgba(var(--gold-rgb), 0); } }

/* ── Modal ────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(17, 24, 39, .55); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__box { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 20px; box-shadow: 0 12px 48px rgba(0, 0, 0, .3); }
.modal__box h2 { margin-top: 0; }
.tabs-nav { display: flex; border-bottom: 1px solid var(--gray-200); margin-bottom: 14px; gap: 4px; }
.tabs-nav button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 14px; font: inherit; font-weight: 600; color: var(--gray-600); cursor: pointer; }
.tabs-nav button.active { color: var(--navy-deep); border-bottom-color: var(--gold); }
.draw-canvas { width: 100%; height: 180px; border: 1px dashed var(--gray-500); border-radius: var(--radius); background: var(--white); touch-action: none; display: block; cursor: crosshair; }
.type-preview { border: 1px solid var(--gray-300); background: var(--gray-100); border-radius: var(--radius); height: 110px; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; overflow: hidden; margin: 10px 0; padding: 0 12px; white-space: nowrap; }
.style-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.style-picker button { border: 1px solid var(--gray-300); background: var(--white); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; font-size: 1.25rem; }
.style-picker button.active { border-color: var(--gold); box-shadow: var(--focus-ring); }
.legal { font-size: .75rem; color: var(--gray-600); margin: 14px 0; }
.consent-text { max-height: 320px; overflow-y: auto; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 12px 14px; background: var(--gray-100); font-size: .9rem; margin-bottom: 14px; }
.center { text-align: center; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--gray-300); border-top-color: var(--gold); border-radius: 50%; display: inline-block; animation: spin 1s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.code-block { background: var(--gray-900); color: #e5e7eb; padding: 14px; border-radius: var(--radius); overflow-x: auto; font-size: .82rem; white-space: pre; }
.err-big { font-family: var(--font-heading); font-size: 4rem; color: var(--gold); margin: 0; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1000px) {
  .editor-layout { grid-template-columns: 1fr 240px; }
  .editor-docs { display: none; }
}
@media (max-width: 720px) {
  /* Four links do not fit beside the logo on a phone: the link row scrolls sideways instead of widening the page. */
  .navbar { gap: 14px; }
  .nav-links { gap: 14px; min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { flex: none; font-size: .85rem; }
  .nav-user { flex: none; }
  .nav-user .nav-name { display: none; }
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--gray-200); }
  .table.responsive td { border: 0; padding: 2px 0; }
  .table.responsive td[data-label]::before { content: attr(data-label) ': '; font-size: .7rem; text-transform: uppercase; color: var(--gray-600); letter-spacing: .05em; }
  .recipient-row { grid-template-columns: 1fr 1fr; }
  .recipient-row--role { grid-template-columns: 1fr 96px; }
  .recipient-row--role .remove-recipient { margin-top: 19px; justify-self: end; }
  .recipient-row--use { grid-template-columns: 1fr; }
  .recipient-row--use .role-cell { padding-top: 0; }
  .template-pick__form { flex-direction: column; align-items: stretch; width: 100%; }
  .template-pick__form select { flex: none; width: 100%; }
  .kv { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .editor-palette { border-left: 0; border-top: 1px solid var(--gray-200); max-height: 42vh; }
  .signer-top .btn { padding: 7px 12px; }
  .consent-bar { position: static; }
  .timeline__step { font-size: .72rem; }
}

/* ── Progress bars ────────────────────────────────────── */
.pbar { height: 8px; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.pbar__fill { height: 100%; width: 0; border-radius: 999px; background: var(--gold); transition: width .25s ease; }
.pbar__fill--done { background: var(--success); }
.pbar__fill--bad { background: var(--danger); }
.pbar--dark { background: rgba(255, 255, 255, .18); }
.pbar--sm { height: 5px; width: 72px; display: inline-block; vertical-align: middle; margin-left: 8px; }
.pbar--sm .pbar__fill { display: block; }
.signing-progress { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; font-size: .85rem; color: var(--gray-600); }
.signing-progress .pbar { flex: 1; }
.signing-progress strong { color: var(--gray-900); white-space: nowrap; }

/* ── Utilities ────────────────────────────────────────── */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.m-0 { margin: 0 !important; }
form.inline { display: inline; }
.table-wrap.flat { box-shadow: none; }
.btn-onDark { color: var(--white); border-color: var(--gray-500); background: transparent; }
.btn-onDark:hover:not([disabled]) { background: var(--white); color: var(--navy-deep); }
.link-light { color: var(--on-dark); opacity: .85; }
.flashes { flex: none; width: 100%; }

/* ── White-label branding ─────────────────────────────── */
.brand-logo { height: 32px; width: auto; max-width: 180px; object-fit: contain; display: block; }
.brand-link { display: inline-flex; align-items: center; }
.brand-link:hover { text-decoration: none; }
.nav-name { color: var(--on-dark); opacity: .85; }
.subnav { display: flex; gap: 18px; margin-bottom: 16px; }
.subnav a { color: var(--gray-600); font-weight: 500; padding: 4px 0; border-bottom: 2px solid transparent; }
.subnav a:hover { color: var(--navy-deep); text-decoration: none; }
.subnav a.active { color: var(--navy-deep); font-weight: 700; border-bottom-color: var(--gold); }
.color-field { display: flex; gap: 10px; align-items: center; }
.color-field input[type=color] { width: 44px; height: 36px; padding: 0; border: 1px solid var(--gray-300); border-radius: 6px; background: var(--white); cursor: pointer; }
.color-field input[type=text] { max-width: 140px; font-family: monospace; }
.logo-current { display: flex; gap: 16px; align-items: center; margin-top: 10px; padding: 10px; background: var(--gray-100); border-radius: var(--radius); }
.brand-preview { padding: 0; overflow: hidden; }
.brand-preview__header { background: var(--bp-primary, var(--navy-deep)); color: var(--bp-on-primary, #fff); padding: 16px 20px; display: flex; align-items: center; gap: 12px; border-radius: var(--radius) var(--radius) 0 0; }
.brand-preview__name { font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem; }
.brand-preview__rule { height: 3px; background: var(--bp-accent, var(--gold)); }
.brand-preview__body { padding: 20px; }
.brand-preview__btn { background: var(--bp-accent, var(--gold)); color: var(--bp-on-accent, var(--navy-deep)); border-color: var(--bp-accent, var(--gold)); border-bottom: 3px solid var(--bp-accent-dark, var(--gold-dark)); cursor: default; }
.brand-preview__fill { background: var(--bp-accent, var(--gold)); width: 60%; }
