/* ==========================================================================
   eSign — design tokens & components
   ========================================================================== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e6ef;
  --border-strong: #cdd3e0;
  --text: #161b2e;
  --text-2: #4a5268;
  --muted: #7b8399;
  --primary: #2a54e6;
  --primary-600: #1f43c4;
  --primary-50: #eef2ff;
  --success: #12a150;
  --success-50: #e7f7ee;
  --warning: #c27803;
  --warning-50: #fff6e0;
  --danger: #d92d3a;
  --danger-50: #fdecee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 48, .06);
  --shadow: 0 4px 16px rgba(16, 24, 48, .08), 0 1px 3px rgba(16, 24, 48, .06);
  --shadow-lg: 0 20px 50px rgba(16, 24, 48, .18);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 60px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
img, svg { display: block; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 18px; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #3d6bff, #1f3fc0);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 3px 8px rgba(42, 84, 230, .35);
}
.nav-links { display: flex; gap: 4px; margin-left: 12px; }
.nav-links a { color: var(--text-2); padding: 7px 12px; border-radius: 8px; font-weight: 550; font-size: 14px; }
.nav-links a:hover, .nav-links a.active { background: var(--primary-50); color: var(--primary); text-decoration: none; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-50); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  border: none; cursor: pointer;
}
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; z-index: 60;
}
.menu-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-pop button, .menu-pop a {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px;
  background: none; border: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; font-size: 14px;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 750; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card h2 { font-size: 16px; font-weight: 700; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }

/* ---------- buttons ---------- */
.btn {
  --b: var(--surface); --c: var(--text); --bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  background: var(--b); color: var(--c); border: 1px solid var(--bd);
  font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible { outline: 3px solid rgba(42, 84, 230, .3); outline-offset: 1px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { --b: var(--primary); --c: #fff; --bd: var(--primary); box-shadow: 0 2px 6px rgba(42, 84, 230, .25); }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { --b: var(--success); --c: #fff; --bd: var(--success); }
.btn-success:hover { background: #0e8a44; }
.btn-danger { --c: var(--danger); --bd: #f2c4c8; }
.btn-danger:hover { background: var(--danger-50); }
.btn-ghost { --b: transparent; --bd: transparent; --c: var(--text-2); }
.btn-ghost:hover { background: rgba(16, 24, 48, .05); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 34px; padding: 0; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: 400 14.5px var(--font);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(42, 84, 230, .15); }
.input-sm { height: 32px; font-size: 13.5px; padding: 0 9px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 20px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
.error-text { color: var(--danger); font-size: 13.5px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.draft { color: #5b6478; }
.badge.sent, .badge.pending { color: var(--warning); background: var(--warning-50); border-color: #f6e1ad; }
.badge.completed, .badge.signed { color: var(--success); background: var(--success-50); border-color: #bfe8cf; }
.badge.declined, .badge.voided { color: var(--danger); background: var(--danger-50); border-color: #f6c9cd; }
.badge.waiting { color: #6b7280; }

/* ---------- toasts & modals ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1b2236; color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500; animation: toast-in .25s ease; max-width: min(520px, 92vw);
}
.toast.error { background: var(--danger); }
.toast.success { background: #0f7a3f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 900; background: rgba(15, 20, 40, .5);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  animation: pop .2s ease;
}
.modal.wide { width: min(720px, 100%); }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 0; }
.modal-head h3 { font-size: 18px; font-weight: 700; }
.modal-head .btn-ghost { margin-left: auto; }
.modal-body { padding: 16px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; }

/* ---------- landing ---------- */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; max-width: 1120px; margin: 0 auto; padding: 64px 24px 40px; }
.hero h1 { font-size: clamp(32px, 4.6vw, 50px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, #2a54e6, #7b4dff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: 18px; color: var(--text-2); margin: 18px 0 26px; max-width: 540px; }
.hero-points { display: grid; gap: 10px; margin-top: 8px; }
.hero-points div { display: flex; gap: 10px; align-items: center; color: var(--text-2); }
.hero-points svg { color: var(--success); width: 20px; height: 20px; flex: none; }
.auth-card { padding: 28px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tabs button { height: 36px; border: 0; border-radius: 7px; background: none; font: 600 14px var(--font); color: var(--text-2); cursor: pointer; }
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.steps { max-width: 1120px; margin: 0 auto; padding: 10px 24px 80px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.step { padding: 22px; }
.step .num { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 800; margin-bottom: 14px; }
.step h3 { font-size: 16px; margin-bottom: 6px; }
.step p { color: var(--text-2); font-size: 14px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

/* ---------- dashboard ---------- */
.dropzone {
  display: block;
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 34px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-50); }
.dropzone .icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; }
.dropzone .icon svg { width: 26px; height: 26px; }
.dropzone h3 { font-size: 17px; margin-bottom: 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 22px 0; }
.stat { padding: 16px 18px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.stat:hover, .stat.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(42, 84, 230, .1); }
.stat .n { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 600; }
.doc-list { overflow: hidden; }
.doc-toolbar { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.doc-toolbar .input { max-width: 300px; }
.doc-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 190px 120px 40px; gap: 14px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s;
}
.doc-row:last-child { border-bottom: 0; }
.doc-row:hover { background: var(--surface-2); }
.doc-thumb { width: 44px; height: 54px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--danger); }
.doc-thumb svg { width: 22px; height: 22px; }
.doc-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signer-dots { display: flex; align-items: center; }
.signer-dot {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; margin-left: -6px;
}
.signer-dot:first-child { margin-left: 0; }
.signer-dot.signed { box-shadow: 0 0 0 2px var(--success); }
.signer-dot.declined { box-shadow: 0 0 0 2px var(--danger); }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 46px; height: 46px; margin: 0 auto 12px; color: var(--border-strong); }

/* ---------- PDF viewer ---------- */
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px 16px 80px; }
.pdf-page {
  position: relative; width: 100%; background: #fff;
  box-shadow: 0 2px 10px rgba(16, 24, 48, .12), 0 0 0 1px rgba(16, 24, 48, .05);
  border-radius: 2px; user-select: none; -webkit-user-select: none;
}
.pdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 2px; }
.pdf-page .overlay { position: absolute; inset: 0; }
.page-label { position: absolute; bottom: -19px; right: 0; font-size: 12px; color: var(--muted); }
.pdf-loading { display: grid; place-items: center; min-height: 300px; color: var(--muted); gap: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - var(--nav-h)); }
.editor-side { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.side-section { padding: 18px; border-bottom: 1px solid var(--border); }
.editor-main { overflow: auto; background: #e9ecf3; position: relative; }
.editor-main .pdf-pages { max-width: 940px; margin: 0 auto; }
.editor-bar { display: flex; align-items: center; gap: 10px; }
.title-input { border: 1px solid transparent; background: transparent; font: 700 16px var(--font); color: var(--text); padding: 6px 8px; border-radius: 6px; min-width: 0; width: 100%; max-width: 420px; }
.title-input:hover { border-color: var(--border); }
.title-input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.save-state { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.signer-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 10px 10px 12px; position: relative; background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.signer-card + .signer-card { margin-top: 10px; }
.signer-card.active { border-color: var(--sc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc) 18%, transparent); }
.signer-card::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--sc); }
.signer-card .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.signer-card .order { width: 22px; height: 22px; border-radius: 50%; background: var(--sc); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; flex: none; }
.signer-card .count { font-size: 12px; color: var(--muted); margin-left: auto; }
.signer-card .inputs { display: grid; gap: 6px; }
.signer-card .more { display: none; }
.signer-card.active .more { display: grid; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool {
  display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); cursor: grab; font-size: 13.5px; font-weight: 600; color: var(--text);
  touch-action: none; user-select: none; transition: border-color .15s, background .15s;
}
.tool:hover { border-color: var(--sc, var(--primary)); background: color-mix(in srgb, var(--sc, var(--primary)) 7%, #fff); }
.tool svg { width: 17px; height: 17px; color: var(--sc, var(--primary)); flex: none; }
.tool.armed { border-color: var(--sc); background: color-mix(in srgb, var(--sc) 12%, #fff); }
.drag-ghost { position: fixed; z-index: 999; pointer-events: none; opacity: .9; border: 2px solid var(--sc); background: color-mix(in srgb, var(--sc) 18%, #fff); border-radius: 4px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--sc); }
.placing .overlay { cursor: crosshair; }

.f {
  position: absolute; border: 1.5px solid var(--sc); background: color-mix(in srgb, var(--sc) 14%, rgba(255,255,255,.55));
  border-radius: 3px; display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-size: 12px; font-weight: 650; color: color-mix(in srgb, var(--sc) 80%, #000); cursor: move; touch-action: none;
  container-type: size;
}
.f .flabel { display: flex; align-items: center; gap: 5px; pointer-events: none; white-space: nowrap; padding: 0 4px; font-size: clamp(8px, 40cqh, 13px); }
.f .flabel svg { width: 1.2em; height: 1.2em; }
.f.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sc); z-index: 5; }
.f .rs { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; background: var(--sc); cursor: nwse-resize; border-radius: 3px 0 2px 0; }
.f .optional { position: absolute; top: 1px; right: 3px; font-size: 9px; font-weight: 600; opacity: .7; pointer-events: none; }
.f-toolbar {
  position: absolute; z-index: 20; display: flex; gap: 4px; align-items: center; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  transform: translateY(-100%); margin-top: -8px; white-space: nowrap;
}
.f-toolbar select { height: 30px; font-size: 13px; padding: 0 6px; max-width: 160px; }
.f-toolbar .btn { height: 30px; }
.f-toolbar .switch { font-size: 12.5px; padding: 0 6px; gap: 6px; }
.f-toolbar .switch input { width: 30px; height: 17px; }
.f-toolbar .switch input::after { width: 13px; height: 13px; }
.f-toolbar .switch input:checked::after { transform: translateX(13px); }

/* ---------- document detail ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.preview-box { background: #e9ecf3; border-radius: var(--radius); max-height: calc(100vh - 200px); overflow: auto; border: 1px solid var(--border); }
.preview-box .pdf-pages { padding: 20px 14px 30px; gap: 16px; }
.signer-line { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.signer-line:last-child { border-bottom: 0; padding-bottom: 0; }
.signer-line .signer-dot { width: 34px; height: 34px; margin: 0; font-size: 12.5px; flex: none; }
.link-box { display: flex; gap: 6px; margin-top: 8px; }
.link-box input { height: 32px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); }
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 14px; font-size: 13.5px; }
.tl-item::before { content: ""; position: absolute; left: -17px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.tl-item.signed::before, .tl-item.completed::before { border-color: var(--success); background: var(--success); }
.tl-item.declined::before, .tl-item.voided::before { border-color: var(--danger); background: var(--danger); }
.tl-item .when { color: var(--muted); font-size: 12px; }
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: 10px; font-size: 14px; align-items: flex-start; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert.info { background: var(--primary-50); color: #1d3aa8; }
.alert.success { background: var(--success-50); color: #0b6b35; }
.alert.warning { background: var(--warning-50); color: #8a5502; }
.alert.danger { background: var(--danger-50); color: #a01e29; }

/* ---------- signing ---------- */
.sign-shell { min-height: 100vh; display: flex; flex-direction: column; }
.sign-bar {
  position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 10px 20px; min-height: var(--nav-h); flex-wrap: wrap;
}
.sign-bar .doc-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 6px; width: 140px; background: var(--border); border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--success); width: 0; transition: width .3s; }
.sign-main { flex: 1; background: #e9ecf3; }
.sign-main .pdf-pages { max-width: 940px; margin: 0 auto; }
.sign-banner { max-width: 940px; margin: 18px auto 0; padding: 0 16px; }

.sf {
  position: absolute; border: 2px dashed var(--warning); background: rgba(255, 214, 102, .32); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden;
  color: #7a4d00; font-weight: 700; font-size: 12px; transition: background .15s, box-shadow .15s; container-type: size;
}
.sf:hover { background: rgba(255, 214, 102, .55); }
.sf.focus { box-shadow: 0 0 0 3px rgba(255, 170, 0, .5); }
.sf .flabel { display: flex; align-items: center; gap: 5px; pointer-events: none; white-space: nowrap; font-size: clamp(8px, 40cqh, 13px); }
.sf .flabel svg { width: 1.2em; height: 1.2em; }
.sf.filled { border: 1.5px solid rgba(18, 161, 80, .55); background: rgba(18, 161, 80, .06); color: #10204d; }
.sf.optional:not(.filled) { border-color: #a0a8bb; background: rgba(160, 168, 187, .18); color: #4a5268; }
.sf img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.sf .val { font-weight: 500; color: #10204d; font-size: clamp(7px, 62cqh, 15px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; width: 100%; }
.sf input.text-in { width: 100%; height: 100%; border: 0; background: transparent; font: 500 clamp(7px, 62cqh, 15px) var(--font); color: #10204d; padding: 0 4px; outline: none; }
.sf.checkbox-f { cursor: pointer; }
.sf.checkbox-f .tick { font-size: clamp(8px, 80cqh, 22px); line-height: 1; color: #10204d; }
.of {
  position: absolute; border: 1px dashed #a0a8bb; background: rgba(160, 168, 187, .12); border-radius: 3px;
  display: flex; align-items: center; justify-content: center; font-size: 10px; color: #6b7280; pointer-events: none; overflow: hidden; white-space: nowrap;
}
.next-tag {
  position: absolute; z-index: 6; transform: translate(calc(-100% - 10px), -50%); background: var(--warning); color: #fff;
  font-size: 12px; font-weight: 700; padding: 5px 10px 5px 12px; border-radius: 6px 0 0 6px; white-space: nowrap; pointer-events: none;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
  padding-right: 16px;
}

/* signature pad */
.sig-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.sig-tabs button { border: 0; background: none; padding: 9px 14px; font: 600 14px var(--font); color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sig-tabs button.active { color: var(--primary); border-color: var(--primary); }
.pad-wrap { position: relative; border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; touch-action: none; }
.pad-wrap canvas { width: 100%; height: 200px; display: block; cursor: crosshair; border-radius: 10px; }
.pad-wrap .baseline { position: absolute; left: 24px; right: 24px; bottom: 48px; border-bottom: 1.5px solid #d7dbe6; pointer-events: none; }
.pad-wrap .x { position: absolute; left: 22px; bottom: 52px; color: #b6bccb; font-size: 18px; pointer-events: none; }
.pad-wrap .hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b6bccb; pointer-events: none; font-size: 15px; }
.pad-tools { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.ink { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.ink.active { box-shadow: 0 0 0 2px var(--primary); }
.font-choices { display: grid; gap: 8px; margin-top: 12px; max-height: 240px; overflow: auto; }
.font-choice { border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; cursor: pointer; font-size: 30px; line-height: 1.3; background: #fff; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #10204d; }
.font-choice.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(42, 84, 230, .15); }
.upload-sig { border: 2px dashed var(--border-strong); border-radius: 10px; min-height: 180px; display: grid; place-items: center; text-align: center; cursor: pointer; padding: 16px; color: var(--muted); }
.upload-sig img { max-height: 160px; max-width: 100%; }

.done-screen { max-width: 560px; margin: 60px auto; padding: 0 16px; text-align: center; }
.done-screen .big-icon { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 20px; display: grid; place-items: center; background: var(--success-50); color: var(--success); }
.done-screen .big-icon svg { width: 38px; height: 38px; }
.done-screen h1 { font-size: 26px; margin-bottom: 10px; }

/* ---------- verify ---------- */
.verify-box { max-width: 640px; margin: 0 auto; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding-top: 36px; gap: 30px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .preview-box { max-height: 70vh; }
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor-side { border-right: 0; border-bottom: 1px solid var(--border); }
  .editor-main { min-height: 70vh; overflow: visible; }
}
@media (max-width: 720px) {
  .nav { padding: 0 14px; }
  .nav-links { display: none; }
  .container { padding: 20px 16px 48px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr; }
  .doc-row { grid-template-columns: 40px minmax(0, 1fr) 40px; }
  .doc-row .col-signers, .doc-row .col-status { display: none; }
  .doc-row .doc-meta .badge { display: inline-flex; }
  .sign-bar { padding: 10px 14px; }
  .progress { display: none; }
  .pdf-pages { padding: 16px 8px 60px; }
}
