/* Darla eSign design system. Shared by the sender app and the signing page. */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("/static/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("/static/fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("/static/fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("/static/fonts/inter-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 500; font-display: swap; src: url("/static/fonts/fraunces-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 600; font-display: swap; src: url("/static/fonts/fraunces-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Dancing Script"; font-weight: 600; font-display: swap; src: url("/static/fonts/dancing-script-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Caveat"; font-weight: 600; font-display: swap; src: url("/static/fonts/caveat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Sacramento"; font-weight: 400; font-display: swap; src: url("/static/fonts/sacramento-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Homemade Apple"; font-weight: 400; font-display: swap; src: url("/static/fonts/homemade-apple-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Great Vibes"; font-weight: 400; font-display: swap; src: url("/static/fonts/great-vibes-latin-400-normal.woff2") format("woff2"); }

:root {
  --ink: #0f1b33;
  --ink-2: #1c2a47;
  --ink-soft: #33415c;
  --paper: #f5f3ee;
  --paper-2: #efece4;
  --surface: #ffffff;
  --line: #e4dfd3;
  --line-2: #d3ccbc;
  --muted: #667085;
  --gold: #f6c445;
  --gold-deep: #e0aa1e;
  --gold-ink: #3d2f00;
  --accent: #14284b;
  --green: #17794a; --green-bg: #e6f4ec;
  --red: #b42318; --red-bg: #fdecea;
  --amber: #a15c07; --amber-bg: #fdf3dc;
  --blue: #1d4ed8; --blue-bg: #e8effd;
  --slate-bg: #eef0f4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 51, .06), 0 1px 3px rgba(15, 27, 51, .05);
  --shadow: 0 6px 18px rgba(15, 27, 51, .08), 0 2px 6px rgba(15, 27, 51, .05);
  --shadow-lg: 0 24px 60px rgba(15, 27, 51, .22), 0 6px 18px rgba(15, 27, 51, .1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  /* One color per signer, readable on white. */
  --c0: #f6c445; --c0-bg: rgba(246, 196, 69, .28); --c0-ink: #5a4300;
  --c1: #4f8ff7; --c1-bg: rgba(79, 143, 247, .2); --c1-ink: #123a85;
  --c2: #2fb574; --c2-bg: rgba(47, 181, 116, .2); --c2-ink: #0d5232;
  --c3: #ee6aa7; --c3-bg: rgba(238, 106, 167, .2); --c3-ink: #7c1747;
  --c4: #9a7bf2; --c4-bg: rgba(154, 123, 242, .2); --c4-ink: #3f2594;
  --c5: #f98a3c; --c5-bg: rgba(249, 138, 60, .22); --c5-ink: #7a3606;
  --cx: #94a3b8; --cx-bg: rgba(148, 163, 184, .22); --cx-ink: #334155;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-family: var(--display); font-weight: 600; font-size: 28px; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.005em; }
h3 { font-size: 14px; font-weight: 600; }
a { color: var(--accent); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14.5px; line-height: 1; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; user-select: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--ink-2); }
.btn-gold { background: var(--gold); color: var(--gold-ink); box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, var(--shadow-sm); }
.btn-gold:hover { background: #f8cf63; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: #faf9f6; border-color: #bdb5a2; }
.btn-quiet { background: transparent; color: var(--ink-soft); }
.btn-quiet:hover { background: rgba(15, 27, 51, .06); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #f0c4be; }
.btn-danger:hover { background: var(--red-bg); }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 16px; border-radius: 12px; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-ghost.is-busy::after, .btn-gold.is-busy::after, .btn-quiet.is-busy::after, .btn-danger.is-busy::after { border-color: rgba(15,27,51,.2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.link-quiet { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.link-quiet:hover { color: var(--ink); }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field small { color: var(--muted); font-size: 12.5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; background: #fff; border: 1px solid var(--line-2); border-radius: 10px; font-size: 15px; transition: border-color .15s, box-shadow .15s; appearance: none; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23667085' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
input::placeholder, textarea::placeholder { color: #9aa1ae; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14.5px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 40px; height: 24px; border-radius: 99px; background: #cfd4dc; position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- Surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start; }
.alert-error { background: var(--red-bg); color: #7a1a12; border-color: #f3c9c4; }
.alert-warn { background: var(--amber-bg); color: #6b3d05; border-color: #f1dca6; }
.alert-ok { background: var(--green-bg); color: #0f5132; border-color: #bfe3cf; }
.alert-info { background: var(--blue-bg); color: #173a8c; border-color: #c6d6fa; }
.alert .btn { margin-left: auto; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-draft { background: var(--slate-bg); color: #475467; }
.pill-sent, .pill-completing { background: var(--amber-bg); color: var(--amber); }
.pill-completed { background: var(--green-bg); color: var(--green); }
.pill-declined, .pill-voided, .pill-expired { background: var(--red-bg); color: var(--red); }
.pill-action { background: var(--gold); color: var(--gold-ink); }
.pill-template { background: var(--blue-bg); color: var(--blue); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--cx); }
.dot.c0 { background: var(--c0); } .dot.c1 { background: var(--c1); } .dot.c2 { background: var(--c2); }
.dot.c3 { background: var(--c3); } .dot.c4 { background: var(--c4); } .dot.c5 { background: var(--c5); }

/* ---- Toasts ---- */
.toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; animation: toast-in .2s ease-out; pointer-events: auto; max-width: 440px; }
.toast.is-error { background: #8f1d14; }
.toast.is-ok { background: #0f5d38; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---- Modal and sheet ---- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 18, 36, .55); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; animation: pop .18s ease-out; }
.modal-wide { max-width: 680px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.modal-head h2 { font-family: var(--display); font-size: 21px; font-weight: 600; flex: 1; }
.modal-body { padding: 10px 20px 18px; overflow-y: auto; }
.modal-foot { padding: 14px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.x-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; color: var(--muted); }
.x-btn:hover { background: var(--slate-bg); color: var(--ink); }
.x-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
@media (max-width: 640px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); animation: sheet .22s ease-out; }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
}

/* ---- Menus ---- */
.menu { position: absolute; z-index: 90; min-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 8px; font-size: 14px; text-align: left; text-decoration: none; color: var(--ink); }
.menu button:hover, .menu a:hover { background: var(--paper); }
.menu .danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; opacity: .75; }

/* ---- Document pages with fields on top (editor, signing, preview) ---- */
.doc-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 18px 12px 120px; }
.doc-file-label { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-bottom: -6px; }
.doc-page { position: relative; width: 100%; background: #fff; box-shadow: 0 1px 3px rgba(15,27,51,.14), 0 8px 24px rgba(15,27,51,.08); border-radius: 2px; container-type: inline-size; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y pinch-zoom; }
.doc-page > img { display: block; width: 100%; height: 100%; position: absolute; inset: 0; pointer-events: none; -webkit-user-drag: none; }
.doc-page .page-num { position: absolute; right: 8px; bottom: -16px; font-size: 11px; color: var(--muted); }
.doc-page .layer { position: absolute; inset: 0; }
.fld { position: absolute; border-radius: 3px; --fc: var(--cx); --fbg: var(--cx-bg); --fink: var(--cx-ink); }
.fld.c0 { --fc: var(--c0); --fbg: var(--c0-bg); --fink: var(--c0-ink); }
.fld.c1 { --fc: var(--c1); --fbg: var(--c1-bg); --fink: var(--c1-ink); }
.fld.c2 { --fc: var(--c2); --fbg: var(--c2-bg); --fink: var(--c2-ink); }
.fld.c3 { --fc: var(--c3); --fbg: var(--c3-bg); --fink: var(--c3-ink); }
.fld.c4 { --fc: var(--c4); --fbg: var(--c4-bg); --fink: var(--c4-ink); }
.fld.c5 { --fc: var(--c5); --fbg: var(--c5-bg); --fink: var(--c5-ink); }
.fld-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: left center; pointer-events: none; }
.fld-img.is-center { object-position: center; }
.fld-text { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 .5cqw; color: #0f1729; font-family: Helvetica, Arial, sans-serif; white-space: nowrap; overflow: hidden; line-height: 1.2; }
.fld-check { position: absolute; inset: 0; display: grid; place-items: center; }
.fld-check svg { width: 86%; height: 86%; fill: none; stroke: #0f1729; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* Handles on a movable field (editor and free-form signing) */
.fld-resize { position: absolute; right: -7px; bottom: -7px; width: 16px; height: 16px; border-radius: 50%; background: var(--blue); border: 2.5px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); cursor: nwse-resize; display: none; touch-action: none; }
.fld-del { position: absolute; right: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: var(--red); color: #fff; display: none; place-items: center; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.fld.is-selected .fld-resize { display: block; }
.fld.is-selected .fld-del { display: grid; }

/* ---- Signature pad ---- */
.sig-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--paper-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.sig-tabs button { border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.sig-tabs button.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.sig-canvas-wrap { position: relative; border: 1.5px dashed var(--line-2); border-radius: 14px; background: #fff; touch-action: none; overflow: hidden; }
.sig-canvas-wrap canvas { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; }
.sig-canvas-wrap .baseline { position: absolute; left: 22px; right: 22px; bottom: 46px; border-bottom: 1.5px solid #cfd4dc; pointer-events: none; }
.sig-canvas-wrap .baseline::before { content: "\00d7"; position: absolute; left: 0; bottom: 4px; color: #9aa1ae; font-size: 20px; line-height: 1; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa1ae; font-size: 15px; pointer-events: none; }
.sig-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.sig-font { border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding: 10px 12px; height: 68px; font-size: 30px; line-height: 1.2; overflow: hidden; white-space: nowrap; text-overflow: clip; text-align: center; color: #0f1b4d; }
.sig-font.is-active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; }
.sig-upload { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 26px 16px; text-align: center; background: #fff; }
.sig-upload img { max-height: 110px; margin: 0 auto 10px; display: block; }
.sig-legal { margin-top: 12px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
@media (max-width: 480px) { .sig-fonts { grid-template-columns: 1fr; } .sig-font { height: 60px; } }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); font-family: var(--display); font-size: 21px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(15,27,51,.15); border-top-color: var(--ink); animation: spin .7s linear infinite; margin: 60px auto; }
