:root { --bg: #EEF1EF; --panel: #FFFFFF; --ink: #16221D; --muted: #5B6A63; --line: #D6DDD8; --accent: #1B6EC2; --accent-soft: #DCEAF8; --hover: #F1F4F2; --danger: #B3392A; --ok: #2E7D4F; --me: #1B6EC2; color-scheme: light; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 400 15px/1.5 "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; font-weight: 700; font-stretch: 110%; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .nowrap { white-space: nowrap; }

/* top bar */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 20px; padding-top: env(safe-area-inset-top, 0px); background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-size: 16px; }
.brand b { font-weight: 700; font-stretch: 112%; }
.mark { width: 26px; height: 26px; color: var(--accent); }
.spacer { flex: 1; }
.nav { display: flex; align-items: center; gap: 16px; }
.nav > a:not(.btn) { color: var(--muted); text-decoration: none; font-weight: 550; }
.nav > a:not(.btn):hover { color: var(--ink); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 600 14.5px/1 inherit; font-family: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #155DA6; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13.5px; }
.btn.big { height: 46px; padding: 0 22px; font-size: 16px; width: 100%; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.icon-only { width: 38px; padding: 0; font-size: 20px; }

/* page shells */
main.narrow { max-width: 580px; margin: 40px auto; }
main.wide { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; }
body.center main.narrow { margin: max(40px, 12vh) auto 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px 28px; box-shadow: 0 1px 2px rgba(10, 30, 20, .04); }
main.narrow.card { width: calc(100% - 32px); }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.pagehead p { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { margin: 0 0 10px; } .crumb a { text-decoration: none; color: var(--muted); font-weight: 550; }
.empty { text-align: center; padding: 44px 28px; } .empty p { max-width: 460px; margin: 8px auto 18px; color: var(--muted); }
.notice { text-align: center; } .notice p { color: var(--muted); }
.tick { width: 56px; height: 56px; margin: 4px auto 14px; display: grid; place-items: center; border-radius: 50%; background: #DDF1E4; color: var(--ok); font-size: 28px; font-weight: 700; }

/* forms */
.form { display: grid; gap: 14px; margin-top: 18px; }
.form label, .lbl { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.form small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
fieldset { border: 0; padding: 0; margin: 6px 0 0; display: grid; gap: 14px; }
legend { font-weight: 700; font-size: 15px; margin-bottom: 10px; padding: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex !important; align-items: center; gap: 9px; font-weight: 550; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; }
.check.big { font-size: 16px; margin: 6px 0; }
.checks { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 6px; font-size: 14px; }
.checks li::before { content: "✓"; display: inline-block; width: 22px; color: var(--ok); font-weight: 700; }
.checks li.no::before { content: "✕"; color: var(--danger); }
.checks li span { display: block; margin-left: 22px; color: var(--muted); font-size: 13px; }
.okmsg, .errmsg { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.okmsg { background: #E3F4E9; color: #1D5C37; } .errmsg { background: #FBE7E4; color: #8A2A1E; }
.err { color: var(--danger); font-size: 13.5px; min-height: 1em; margin: 8px 0 0; }

/* lists */
.table-wrap { padding: 0; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; padding: 14px 18px; border-bottom: 1px solid var(--line); }
table.list td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; } table.list tbody tr:hover { background: var(--hover); }
table.list td a { color: var(--ink); font-weight: 600; text-decoration: none; }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; background: #E7ECE9; color: #44524b; white-space: nowrap; }
.s-in_progress, .s-sent { background: #DCEAF8; color: #134E8A; } .s-viewed { background: #EDE3F7; color: #5B2D91; }
.s-completed, .s-signed { background: #DDF1E4; color: #1D5C37; } .s-declined, .s-not_sent { background: #FBE2DE; color: #8A2A1E; } .s-voided { background: #ECEDEC; color: #5B6A63; }
.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
.signers { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.signers li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.signers li:last-child { border-bottom: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.who { display: grid; } .who .muted { font-size: 13.5px; } .when { font-size: 12.5px; color: var(--muted); }
.row-actions { grid-column: 2 / -1; display: flex; gap: 8px; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.history li { display: grid; gap: 1px; padding: 9px 0 9px 16px; border-left: 2px solid var(--line); position: relative; }
.history li::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.history .t { color: var(--muted); font-size: 12px; } .history .ip { color: var(--muted); font-size: 11.5px; }

/* toasts, menus, modals */
.toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 24px); }
.toast { padding: 11px 16px; border-radius: 10px; background: var(--ink); color: #EEF4F0; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.menu { position: fixed; z-index: 60; min-width: 210px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 34px rgba(10, 30, 20, .18); display: grid; }
.menu a, .menu button { display: block; text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--hover); } .menu .danger { color: var(--danger); }
.modal-back { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(8, 20, 14, .45); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; border-radius: 16px; background: #fff; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal h2 { font-size: 20px; margin-bottom: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.disclosure { font-size: 14px; line-height: 1.55; color: #33413a; background: var(--hover); padding: 12px 14px; border-radius: 10px; }
.tabs { display: inline-flex; padding: 3px; margin-bottom: 14px; background: var(--hover); border-radius: 10px; }
.tabs button { height: 34px; padding: 0 18px; border: 0; border-radius: 8px; background: transparent; font: 600 14px inherit; font-family: inherit; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.styles { display: grid; gap: 8px; margin-top: 12px; }
.styles button { min-height: 64px; padding: 6px 16px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.styles button[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.padwrap { position: relative; height: 190px; border: 1.5px dashed var(--line); border-radius: 12px; background: #fff; }
.pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.padline { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1.5px solid #CFD8D2; pointer-events: none; }
.pane .clear { margin-top: 8px; }

/* document panes */
.docpane { position: relative; overflow-y: auto; padding: 28px; background: #E3E8E5; }
.pages { display: grid; gap: 22px; max-width: 880px; margin: 0 auto; }
.pg { position: relative; width: 100%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15), 0 8px 24px rgba(10, 30, 20, .12); }
.pg canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ov { position: absolute; inset: 0; }
.docempty { display: grid; place-items: center; min-height: 60vh; color: var(--muted); border: 2px dashed #C5CEC8; border-radius: 16px; }
.docpane.dragging { outline: 3px dashed var(--accent); outline-offset: -10px; }
body.busy, body.busy * { cursor: progress !important; }

/* prepare */
body.prep-page { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.prep { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }
.side { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 18px 0; display: flex; flex-direction: column; gap: 6px; }
.side section { padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.side h2 { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 15px; }
.side h2 .n { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; }
.side h2 .for { margin-left: auto; font-size: 13px; font-weight: 650; }
.side h2 .opt { margin-left: auto; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.drop { display: grid; gap: 2px; justify-items: center; padding: 18px 12px; border: 2px dashed #C5CEC8; border-radius: 12px; text-align: center; cursor: pointer; background: var(--hover); }
.drop:hover { border-color: var(--accent); } .drop b { color: var(--accent); word-break: break-word; } .drop span { font-size: 12.5px; color: var(--muted); }
.drop.has { border-style: solid; background: #fff; }
.slist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.srow { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; padding: 8px; border: 1.5px solid var(--line); border-radius: 12px; }
.srow.active { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.srow .pick { width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; padding: 0; margin-top: 4px; }
.srow .pick .dot { width: 16px; height: 16px; background: var(--c); box-shadow: 0 0 0 3px #fff, 0 0 0 4.5px var(--c); }
.srow .pick[aria-pressed="false"] .dot { box-shadow: none; opacity: .75; }
.srow .inputs { display: grid; gap: 6px; } .srow input { min-height: 34px; padding: 5px 9px; font-size: 14px; }
.srow .rm { width: 30px; height: 30px; margin-top: 4px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.srow .rm:hover:not(:disabled) { background: var(--hover); color: var(--danger); } .srow .rm:disabled { opacity: .25; cursor: default; }
.row { display: flex; gap: 8px; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pal { height: 36px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font: 600 13.5px inherit; font-family: inherit; color: var(--ink); cursor: pointer; text-align: left; padding: 0 12px; }
.pal:hover { background: var(--hover); } .pal[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tip { margin: 0; font-size: 13px; color: var(--muted); }
.fopts { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--hover); }
.sendbar { position: sticky; bottom: 0; margin-top: auto; padding: 14px 0 18px; background: var(--panel); }
.prep .docpane { height: 100%; }
body.placing .pg { cursor: crosshair; }
.fld { position: absolute; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 13%, rgba(255,255,255,.55)); border-radius: 4px; cursor: move; touch-action: none; user-select: none; overflow: visible; }
.fld .fl { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 6px; overflow: hidden; line-height: 1.1; color: color-mix(in srgb, var(--c) 80%, #000); font-size: calc(var(--k, 1) * 9.5px); }
.fld .fl b { font-weight: 700; white-space: nowrap; } .fld .fl i { font-style: normal; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fld.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); z-index: 2; }
.fld .rz { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: #fff; border: 2px solid var(--c); cursor: nwse-resize; }
.fld .del { position: absolute; right: -11px; top: -11px; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }

/* signing */
body.sign-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.signbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.sb-title { flex: 1; min-width: 0; display: grid; } .sb-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15.5px; } .sb-title .muted { font-size: 13px; }
.sb-progress { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
#finish:not(.ready) { background: #8DB4DD; border-color: #8DB4DD; }
.sendnote { padding: 10px 20px; background: #FFF8E4; border-bottom: 1px solid #F1E2B5; font-size: 14px; }
.docpane.signing { flex: 1; }
.sf { position: absolute; border: 1.5px dashed var(--me); background: color-mix(in srgb, var(--me) 9%, rgba(255,255,255,.6)); border-radius: 4px; color: #0F1714; font-family: Helvetica, Arial, sans-serif; }
.sf.todo { border-style: solid; background: color-mix(in srgb, #F2C230 32%, rgba(255,255,255,.7)); border-color: #C99A10; }
.sf.sig { display: grid; place-items: center; padding: 0; cursor: pointer; overflow: hidden; }
.sf.sig .ph { font: 700 calc(var(--k, 1) * 10px) "Archivo", sans-serif; color: #7A5A00; text-transform: uppercase; letter-spacing: .04em; }
.sf.sig.filled { border-style: solid; border-color: transparent; background: transparent; }
.sf.sig.filled:hover { border-color: var(--me); border-style: dashed; }
.sf.sig img { width: 100%; height: 100%; object-fit: contain; }
.sf.txt { min-height: 0; padding: 0 calc(var(--k, 1) * 2px); border-radius: 3px; line-height: 1.15; resize: none; }
textarea.sf.txt { padding-top: calc(var(--k, 1) * 2px); }
.sf.txt:focus { box-shadow: none; border-style: solid; }
.sf.chk { padding: 0; cursor: pointer; display: grid; place-items: center; font: 700 calc(var(--k, 1) * 12px) sans-serif; }
.sf.chk[aria-checked="true"]::after { content: "✓"; }
.sf.auto { display: flex; align-items: center; padding: 0 calc(var(--k, 1) * 2px); white-space: nowrap; overflow: hidden; border-style: solid; border-color: transparent; background: color-mix(in srgb, var(--me) 7%, transparent); }
.sf.flash { animation: flash .9s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, #F2C230 60%, transparent); } }
.of { position: absolute; display: grid; place-items: center; border: 1px dashed #AEB9B2; border-radius: 4px; background: rgba(240, 243, 241, .7); color: #6B7871; font-size: calc(var(--k, 1) * 8px); overflow: hidden; white-space: nowrap; }
.of.done { border-style: solid; background: rgba(227, 244, 233, .65); color: #1D5C37; }
.of .ov-val { color: #0F1714; font: calc(var(--k, 1) * 10px) Helvetica, Arial, sans-serif; justify-self: start; padding-left: 3px; }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  body.prep-page { height: auto; overflow: visible; }
  .prep { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .prep .docpane { height: auto; min-height: 70vh; }
}
@media (max-width: 640px) {
  .top { padding: 0 14px; } .nav { gap: 10px; } .nav > a:not(.btn):first-child { display: none; }
  .card { padding: 20px; } main.wide { padding: 20px 12px 50px; }
  .grid2 { grid-template-columns: 1fr; }
  .docpane { padding: 12px 8px 40px; } .pages { gap: 14px; }
  .signbar { padding: 8px 10px; gap: 6px; flex-wrap: wrap; } .sb-title { flex-basis: 100%; } .sb-progress { flex: 1; }
  .sendnote { padding: 8px 12px; }
  table.list th:nth-child(2), table.list td:nth-child(2), table.list th:nth-child(4), table.list td:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sf.flash { animation: none; } }

/* public links */
h2.sect { margin: 26px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.s-open { background: #DDF1E4; color: #1D5C37; } .s-closed { background: #ECEDEC; color: #5B6A63; }
.tabs button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tabs.mode { display: flex; margin: 0; } .tabs.mode button { flex: 1; padding: 0 8px; font-size: 13px; }
.stack { display: grid; gap: 10px; }
.lbl.inline { display: flex; align-items: center; gap: 8px; font-weight: 550; } .lbl.inline input { width: 96px; min-height: 34px; padding: 5px 9px; }
.linkbox { display: flex; gap: 8px; } .linkbox input { font: 13px ui-monospace, Menlo, monospace; }
.qr { width: 190px; max-width: 100%; margin: 18px 0 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.facts { margin: 14px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.subs { list-style: none; margin: 0; padding: 0; }
.subs li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.subs li:last-child { border-bottom: 0; } .subs a { color: var(--ink); text-decoration: none; }
.start .eyebrow { margin: 0 0 6px; color: var(--accent); font-weight: 650; font-size: 13.5px; }
.start .note { background: #FFF8E4; padding: 10px 14px; border-radius: 10px; font-size: 14.5px; }
.empty.small { padding: 18px; } .empty.small p { margin: 0; }
