:root {
  --green: #233728; --sage: #558769; --cream: #f0ebe6; --ink: #1d1f1c; --muted: #6b6f68;
  --line: #d9d3cb; --paper: #ffffff; --bg: #f6f3ef; --danger: #a63d2f; --amber: #b7791f;
  --c1: #558769; --c2: #2f6fb5; --c3: #b7791f; --c4: #8a4fb5; --c5: #c0564f;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(35,55,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; }
a { color: var(--sage); }
.hidden { display: none !important; }

header.top { background: var(--green); color: var(--cream); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
header.top .brand { display: flex; align-items: center; gap: 12px; }
header.top .brand img { height: 30px; width: auto; display: block; }
header.top .brand .tag { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; opacity: .75; border-left: 1px solid rgba(240,235,230,.35); padding-left: 12px; line-height: 1; }
header.top { padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px calc(16px + env(safe-area-inset-left)); }
.progress, .intro { padding-top: 10px; }
.finishbar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
header.top button { background: transparent; color: var(--cream); border: 1px solid rgba(240,235,230,.35); }

main { max-width: 960px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 6px 0 14px; font-weight: 600; }
h2 { font-size: 17px; margin: 18px 0 10px; font-weight: 600; }
p.help { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }

.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 120px; }
.stack > * + * { margin-top: 10px; }

label.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--sage); outline-offset: 0; border-color: var(--sage); }
textarea { min-height: 80px; resize: vertical; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; min-height: 42px; white-space: nowrap; }
.btn:hover { border-color: var(--sage); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--green); color: var(--cream); border-color: var(--green); }
.btn.primary:hover { background: #2d4733; }
.btn.sage { background: var(--sage); color: #fff; border-color: var(--sage); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 11px; min-height: 34px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px 10px; min-height: 36px; }

.tabs { display: flex; gap: 6px; background: #e8e2da; padding: 4px; border-radius: 10px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 7px; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

.chip { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #e8e2da; color: var(--ink); font-weight: 600; letter-spacing: .01em; }
.chip.draft { background: #e8e2da; } .chip.sent { background: #fdf1d6; color: #7a4f10; } .chip.completed { background: #dcebdf; color: #1f4a2b; } .chip.voided { background: #f3dcd8; color: #7a2a20; }
.chip.signed { background: #dcebdf; color: #1f4a2b; } .chip.pending { background: #fdf1d6; color: #7a4f10; }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.steps { display: flex; gap: 6px; margin: 0 0 14px; }
.steps div { flex: 1; text-align: center; font-size: 12px; padding: 8px 4px; border-radius: 8px; background: #e8e2da; color: var(--muted); }
.steps div.active { background: var(--green); color: var(--cream); font-weight: 600; }
.steps div.done { background: #dcebdf; color: #1f4a2b; }

.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px 16px; text-align: center; color: var(--muted); background: #fff; }
.dropzone.over { border-color: var(--sage); background: #f1f6f2; }

.signer { display: grid; grid-template-columns: 28px 1fr 1fr auto; gap: 8px; align-items: center; }
.signer .dot { width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
@media (max-width: 560px) { .signer { grid-template-columns: 28px 1fr auto; } .signer input[type=email] { grid-column: 2 / 3; } }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--sage); }

/* field editor */
.toolbar { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.toolbar .tool { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.toolbar .tool.active { border-color: var(--green); background: var(--green); color: var(--cream); }
.pagewrap { position: relative; margin: 0 auto; background: #fff; box-shadow: var(--shadow); touch-action: none; user-select: none; }
.pagewrap canvas { display: block; width: 100%; height: auto; }
.fld { position: absolute; border: 1.5px solid var(--fc, var(--sage)); background: color-mix(in srgb, var(--fc, var(--sage)) 14%, transparent); border-radius: 3px; font-size: 11px; color: var(--fc, var(--sage)); display: flex; align-items: center; padding: 0 4px; overflow: hidden; white-space: nowrap; cursor: move; }
.fld.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
.fld .rs { position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; border-radius: 50%; background: var(--fc, var(--sage)); border: 2px solid #fff; cursor: nwse-resize; }
.fld.cb { justify-content: center; font-size: 10px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 10px 0; }
.placing-hint { background: var(--green); color: var(--cream); border-radius: 8px; padding: 10px 12px; margin: 8px 0; text-align: center; }
.fieldprops { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 12px; box-shadow: 0 -4px 14px rgba(0,0,0,.08); z-index: 4; border-radius: 10px 10px 0 0; }

/* signer page */
.sfld { position: absolute; border: 1.5px solid var(--sage); background: rgba(85,135,105,.14); border-radius: 3px; cursor: pointer; display: flex; align-items: center; padding: 0 4px; font-size: 12px; color: var(--green); overflow: hidden; }
.sfld.done { background: rgba(255,255,255,.75); border-color: var(--sage); }
.sfld.required::after { content: '*'; position: absolute; top: -2px; right: 3px; color: var(--danger); font-weight: 700; }
.sfld img { max-width: 100%; max-height: 100%; }
.sfld.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(85,135,105,.6); } 50% { box-shadow: 0 0 0 6px rgba(85,135,105,0); } }
.sfld.other { border-style: dashed; border-color: #aaa; background: rgba(0,0,0,.03); color: #888; cursor: default; }
.sfld .tick { font-size: 16px; font-weight: 700; }

.sheet { position: fixed; inset: 0; background: rgba(29,31,28,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet .panel { background: #fff; width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 18px 16px 24px; max-height: 92vh; overflow: auto; }
@media (min-width: 600px) { .sheet { align-items: center; } .sheet .panel { border-radius: 16px; } }
.sigpad { border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 170px; display: block; }
.sigline { border-top: 1px dashed var(--line); margin: -40px 20px 30px; pointer-events: none; }
.typed { font-family: "Dancing Script", "Brush Script MT", cursive; font-size: 40px; text-align: center; padding: 20px 10px; min-height: 90px; border: 1px solid var(--line); border-radius: 10px; }
.progress { position: sticky; top: 0; z-index: 6; background: var(--cream); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; z-index: 30; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }
.audit li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.audit li span { color: var(--muted); font-size: 12px; display: block; }
.linkbox { display: flex; gap: 6px; } .linkbox input { font-size: 13px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.center { text-align: center; }
.done-screen { text-align: center; padding: 40px 16px; }
.done-screen .big { font-size: 48px; }
@font-face { font-family: "Dancing Script"; font-style: normal; font-weight: 600; font-display: swap; src: url(vendor/dancing-script-latin-600-normal.woff2) format("woff2"); }
