:root {
  --orange: #f68012;
  --orange-hover: #e0700a;
  --orange-ink: #9a4a05;      /* orange dark enough for text on light grounds */
  --orange-wash: #fef2e6;
  --sand: #d3cfc0;
  --sand-light: #e0ddd2;
  --paper-ground: #f5f4f0;
  --ink: #161616;
  --ink-2: #3d3d3a;
  --muted: #6e6b62;
  --line: #e2dfd5;
  --white: #ffffff;
  --ok: #1f7a4d;
  --ok-wash: #e7f4ec;
  --warn-wash: #fff4dc;
  --danger: #b42318;
  --danger-wash: #fdeceb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 22, 22, .04), 0 8px 28px rgba(22, 22, 22, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper-ground);
  color: var(--ink);
  font: 400 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; }
h1, h2, h3 { font-family: Oswald, Inter, sans-serif; font-weight: 500; letter-spacing: .01em; color: var(--ink); margin: 0; }
h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; text-transform: uppercase; }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--orange-ink); }
.lede { color: var(--ink-2); font-size: 16px; margin: 14px 0 0; max-width: 62ch; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .92em; letter-spacing: .02em; }
.strong { font-weight: 600; }

/* ---------- top bar ---------- */
.topbar { background: var(--white); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand img { display: block; height: 28px; width: auto; }
.secure { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 28px 16px 36px; font-size: 12.5px; color: var(--muted); }
.foot .dot { opacity: .6; }

/* ---------- controls ---------- */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
input, textarea {
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--white); border: 1px solid #cfcbbf; border-radius: 10px;
  padding: 11px 13px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(246, 128, 18, .18); }
input::placeholder, textarea::placeholder { color: #a29e92; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1 Inter, sans-serif; letter-spacing: .02em;
  padding: 13px 20px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--white); color: var(--ink); cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: #f1efe8; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1a1205; }
.btn.primary:hover { background: var(--orange-hover); border-color: var(--orange-hover); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.wide { width: 100%; padding: 16px 20px; font-size: 15px; }
.btn:focus-visible, .tab:focus-visible, .link:focus-visible { outline: 3px solid rgba(246, 128, 18, .45); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--orange-ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.alert { margin: 0; padding: 11px 14px; border-radius: 10px; background: var(--danger-wash); color: var(--danger); font-size: 14px; }
.stack { display: grid; gap: 16px; margin-top: 26px; }
.fine { font-size: 13px; color: var(--muted); margin: 22px 0 0; }

/* ---------- sign-in ---------- */
.page-signin main { display: grid; place-items: center; padding: 56px 16px; }
.signin-card {
  width: 100%; max-width: 460px; background: var(--white); border: 1px solid var(--line);
  border-radius: 18px; padding: 40px 36px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.signin-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--orange); }
.signin-card h1 { font-size: 30px; }
.signin-card .lede { font-size: 15px; }

/* ---------- signing page ---------- */
.sign-layout { max-width: 1240px; margin: 0 auto; padding: 44px 24px 24px; }
.intro { margin-bottom: 30px; }
.terms { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 28px 0 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.terms div { background: var(--white); padding: 16px 18px; }
.terms dt { font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.terms dd { margin: 6px 0 0; font-size: 15px; font-weight: 500; color: var(--ink); }

.sign-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }

.doc { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 52px 56px 44px; }
.doc-head { text-align: center; padding-bottom: 26px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.doc-head img { height: 24px; width: auto; display: block; margin: 0 auto 22px; }
.doc-head h2 { font-size: 24px; text-transform: uppercase; letter-spacing: .04em; }
.doc-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.doc-body { font: 400 15.5px/1.68 "Source Serif 4", Georgia, serif; color: #1f1f1d; }
.doc-body p { margin: 0 0 13px; }
.doc-body p.party { padding-left: 26px; }
.doc-body h3 { font-family: Oswald, Inter, sans-serif; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; margin: 30px 0 12px; color: var(--ink); }
.doc-body ol.alpha { list-style: lower-alpha; margin: 0 0 13px; padding-left: 50px; }
.doc-body ol.alpha li { margin-bottom: 6px; padding-left: 4px; }

.fld { background: var(--orange-wash); color: var(--orange-ink); border-bottom: 1.5px dashed var(--orange); padding: 0 4px; border-radius: 3px; font-style: italic; transition: background .2s; }
.fld.filled { background: #fff8ef; color: var(--ink); font-style: normal; font-weight: 600; border-bottom-style: solid; border-bottom-color: #f5b46e; }
.executed .fld, .executed .fld.filled { background: none; border: 0; padding: 0; font-weight: 600; color: inherit; }

.sig-blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; margin-top: 34px; padding-top: 28px; border-top: 1px solid var(--line); }
.sig-party { font-family: Oswald, Inter, sans-serif; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; font-size: 14px; margin: 0 0 10px; }
.sig-line { height: 74px; border-bottom: 1.5px solid var(--ink); display: flex; align-items: flex-end; margin-bottom: 10px; }
.sig-line img { max-height: 70px; width: auto; display: block; }
.sig-line.accepted { align-items: center; height: 74px; margin: 0 0 10px; font-size: 13px; color: var(--muted); font-style: italic; }
.sig-meta { margin: 0 0 4px; font-size: 13.5px; color: var(--ink-2); }
.sig-blocks .fld { font-size: 13.5px; }

.panel { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; overscroll-behavior: contain; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel::before { content: ""; display: block; height: 4px; background: var(--orange); }
.panel form { padding: 6px 24px 24px; }
.step { padding: 20px 0; border-bottom: 1px solid var(--line); display: grid; gap: 13px; }
.step:last-child { border-bottom: 0; padding-bottom: 0; }
.step h3 { font-size: 16px; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 10px; }
.num { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--ink); color: var(--white); font: 600 12px/1 Inter, sans-serif; letter-spacing: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: #f1efe8; border-radius: 10px; padding: 4px; gap: 4px; }
.tab { border: 0; background: transparent; border-radius: 7px; padding: 9px 10px; font: 500 13.5px/1 Inter, sans-serif; color: var(--ink-2); cursor: pointer; }
.tab.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.sigpad { position: relative; }
.sigpad canvas { display: block; width: 100%; aspect-ratio: 4 / 1; background: #fbfaf6; border: 1px dashed #c9c4b5; border-radius: 10px; }
.sigpad[data-pane="drawn"] canvas { cursor: crosshair; touch-action: none; }
.sigpad[data-pane="generated"] .sig-hint { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 0 16px; text-align: center; pointer-events: none; }
.sigpad[data-pane="generated"] .sig-hint[hidden] { display: none; }
.sig-hint { font-size: 12.5px; color: var(--muted); }
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; font-size: 13px; }
.date-line { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.check { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; font-weight: 400; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--orange); padding: 0; }

/* ---------- executed copy ---------- */
.exec { max-width: 920px; margin: 0 auto; padding: 40px 24px 24px; }
.done { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 24px; box-shadow: var(--shadow); }
.done h1 { font-size: 24px; }
.done p { margin: 6px 0 0; color: var(--ink-2); font-size: 14.5px; }
.done-mark { width: 46px; height: 46px; border-radius: 50%; background: var(--ok-wash); color: var(--ok); display: grid; place-items: center; }
.done-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cert { margin-top: 34px; padding: 20px 22px; background: #faf9f5; border: 1px solid var(--line); border-radius: 12px; }
.cert h3 { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 12px; }
.cert dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.cert dl div.wide { grid-column: 1 / -1; }
.cert dt { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cert dd { margin: 2px 0 0; font-size: 13.5px; word-break: break-word; }
.cert .hash { font-size: 12px; }

/* ---------- admin ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 40px 24px; display: grid; gap: 22px; }
.admin-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h2 { font-size: 18px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 16px; }
.invite-form { display: grid; grid-template-columns: 1.3fr 1fr 1.3fr auto; gap: 12px; align-items: end; }
.created { background: var(--ok-wash); border: 1px solid #bfe0cc; border-radius: var(--radius); padding: 18px 22px; }
.created p { margin: 0 0 6px; }
.created p:last-child { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.actions { white-space: nowrap; text-align: right; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: #f1efe8; color: var(--ink-2); }
.pill.ok { background: var(--ok-wash); color: var(--ok); }
.pill.warn { background: var(--warn-wash); color: #8a5a00; }

.preview-bar { background: var(--ink); color: #f5f4f0; font-size: 13.5px; padding: 10px 24px; text-align: center; }
.preview-bar strong { color: var(--orange); text-transform: uppercase; letter-spacing: .1em; font-size: 12px; margin-right: 6px; }
.preview-bar a { color: #fff; margin-left: 8px; }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { margin: 0; }
.inline-email { display: flex; gap: 6px; min-width: 260px; }
.inline-email input { padding: 7px 10px; font-size: 13.5px; }

/* ---------- review-first signing page ---------- */
.page-sign { padding-bottom: 84px; }
.page-sign .sign-layout { max-width: 920px; }
.page-sign .doc { margin-top: 8px; }
.how { list-style: none; margin: 26px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.how li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.how strong { display: block; font-size: 14.5px; }
.how span:not(.num) { display: block; font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.how .num { margin-top: 1px; }
.intro-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.actionbar .intro-actions { margin: 0; flex-wrap: nowrap; }
.doc-end { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); text-align: center; }
.doc-end p { margin: 0; color: var(--muted); font-size: 14px; }
.doc-end .intro-actions { justify-content: center; margin-top: 14px; }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(22, 22, 22, .06); }
.actionbar-inner { max-width: 920px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.actionbar p { margin: 0; font-size: 14px; color: var(--ink-2); }
.actionbar .btn { padding: 11px 18px; }

.sign-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 24px 80px rgba(0, 0, 0, .28); background: var(--white); color: var(--ink); overflow: hidden; }
.sign-dialog[open] { display: flex; }
.sign-dialog::backdrop { background: rgba(22, 22, 22, .5); backdrop-filter: blur(2px); }
.sign-dialog form { display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 48px); }
.dlg-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 22px 26px 16px; border-bottom: 1px solid var(--line); border-top: 4px solid var(--orange); }
.dlg-head .eyebrow { margin-bottom: 6px; }
.dlg-head h2 { font-size: 24px; text-transform: uppercase; }
.dlg-close { border: 0; background: #f1efe8; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); flex: none; }
.dlg-close:hover { background: var(--sand-light); }
.dlg-body { overflow-y: auto; padding: 4px 26px 8px; overscroll-behavior: contain; }
.dlg-body .step { border: 0; margin: 0; padding: 18px 0; border-bottom: 1px solid var(--line); display: grid; gap: 13px; min-width: 0; }
.dlg-body .step:last-of-type { border-bottom: 0; }
.dlg-body legend { padding: 0; margin-bottom: 13px; font-family: Oswald, Inter, sans-serif; font-weight: 500; font-size: 16px; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 10px; float: left; width: 100%; }
.dlg-body legend + * { clear: both; }
.dlg-body .alert { margin: 0 0 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 26px; border-top: 1px solid var(--line); background: #faf9f5; }
.fine-inline { margin: 0; font-size: 13px; color: var(--muted); }
.hide-sm, .hide-xs { display: inline; }
.show-xs { display: none; }
.print-only { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .sign-grid { grid-template-columns: 1fr; }
  .panel { position: static; }
  .terms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .how { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
@media (max-width: 640px) {
  .sign-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .sign-dialog form { max-height: 100dvh; height: 100%; }
  .dlg-head, .dlg-body, .dlg-foot { padding-left: 18px; padding-right: 18px; }
  .actionbar-inner { padding: 10px 16px; }
  .intro-actions .btn { flex: 1 1 auto; }
  .hide-xs { display: none; }
  .show-xs { display: inline; }
  .topbar-inner { padding: 14px 16px; }
  .brand img { height: 22px; }
  .secure { font-size: 12px; }
  .sign-layout, .exec, .admin { padding-left: 16px; padding-right: 16px; padding-top: 28px; }
  .doc { padding: 30px 20px 26px; }
  .doc-body { font-size: 15px; }
  .doc-body p.party { padding-left: 14px; }
  .doc-body ol.alpha { padding-left: 32px; }
  .sig-blocks { grid-template-columns: 1fr; gap: 26px; }
  .panel form { padding: 4px 18px 20px; }
  .row2 { grid-template-columns: 1fr; }
  .signin-card { padding: 32px 22px; }
  .done { grid-template-columns: 1fr; }
  .cert dl { grid-template-columns: 1fr; }
  .invite-form { grid-template-columns: 1fr; }
  .admin-head { align-items: start; }
}

/* ---------- print / PDF ---------- */
@media print {
  @page { margin: 18mm 16mm; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .foot, .no-print, .panel, .intro, .actionbar, .sign-dialog, .preview-bar { display: none !important; }
  .page-sign { padding-bottom: 0; }
  .page-sign .sign-layout { padding: 0; max-width: none; }
  .fld { background: none !important; font-style: normal; color: inherit !important; }
  .print-only { display: block; }
  .draft-note { margin-top: 10px !important; font-size: 9.5pt; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #9a4a05 !important; }
  .fld.filled { border-bottom-color: transparent !important; padding: 0; }
  .fld:not(.filled) { color: transparent !important; border-bottom: 1px solid #000 !important; padding: 0 30px; }
  .exec { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; padding: 0; }
  .doc-body { font-size: 10.5pt; line-height: 1.5; }
  .doc-body h3 { break-after: avoid; }
  .sig-blocks, .cert { break-inside: avoid; }
  .cert { background: #fff; }
}
