/* Contract on screen: original pages, fields in their boxes, a sheet to fill each one. */
.cp-doc { display: grid; gap: 6px; justify-items: center; padding: 12px 0 120px; }
.cp-page { position: relative; width: min(100%, 860px); background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .12), 0 10px 28px -16px rgb(0 0 0 / .35); border-radius: 3px; overflow: hidden; --k: 1; user-select: none; -webkit-user-select: none; }
.cp-page > img { display: block; width: 100%; height: 100%; pointer-events: none; }
.cp-pno { font: 500 .75rem/1 var(--body, system-ui); color: var(--muted, #667); padding: 2px 0 10px; }

.cf { position: absolute; display: flex; align-items: center; padding: 0 calc(1px * var(--k)); margin: 0; border: 0; background: none; color: #000; text-align: start; overflow: hidden;
  font: calc(var(--fs) * var(--k) * 1px)/1.15 Helvetica, Arial, sans-serif; border-radius: calc(2px * var(--k)); }
.cf .cf-text { white-space: nowrap; overflow: hidden; text-overflow: clip; width: 100%; }
/* one line of text stands on the form's line, which may sit a little below the box */
.cf:has(.cf-text.line) { overflow: visible; }
.cf .cf-text.line { position: absolute; left: calc(1px * var(--k)); right: 0; width: auto; line-height: 1; margin-bottom: -.2em; }
.cf .cf-text.multi { white-space: pre-wrap; align-self: flex-start; padding-top: calc(1px * var(--k)); }
.cf img { max-width: 100%; max-height: 100%; margin: auto; display: block; }
.cf .cf-check { margin: auto; font-weight: 700; }
.cf .cf-ph { font: 600 calc(max(7px, 7px * var(--k) * 1.1))/1 var(--body, system-ui); color: #7a4b00; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.cf .cf-ph.other { color: #5b6470; font-weight: 500; }
/* the signer's own fields: easy to spot, required ones marked on the side */
.cf.mine { cursor: pointer; background: rgb(255 210 80 / .28); box-shadow: inset 0 0 0 1.5px rgb(214 150 0 / .9); touch-action: manipulation; }
.cf.mine.req::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: #d14b1f; }
.cf.mine.filled { background: rgb(15 143 99 / .07); box-shadow: inset 0 0 0 1px rgb(15 143 99 / .45); }
.cf.mine.filled.req::before { background: #0f8f63; }
.cf.mine:hover { background: rgb(255 210 80 / .45); }
.cf.mine.filled:hover { background: rgb(15 143 99 / .14); }
.cf.mine:focus-visible { outline: 3px solid #2158c9; outline-offset: 1px; }
.cf.other.t-signature, .cf.other.t-initial { box-shadow: inset 0 0 0 1px rgb(91 100 112 / .35); background: rgb(91 100 112 / .05); }
.cf.other.filled.t-signature, .cf.other.filled.t-initial { box-shadow: none; background: none; }
.cf.flash { animation: cf-flash .9s ease-out; }
@keyframes cf-flash { 0% { box-shadow: inset 0 0 0 2px #2158c9, 0 0 0 6px rgb(33 88 201 / .35); } 100% { box-shadow: inset 0 0 0 1.5px rgb(214 150 0 / .9), 0 0 0 0 rgb(33 88 201 / 0); } }
@media (prefers-reduced-motion: reduce) { .cf.flash { animation: none; outline: 3px solid #2158c9; } }

/* the sheet: from the bottom on phones, a centred card on wide screens */
.cs-sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh; border-radius: 22px 22px 0 0; background: var(--surface, #fff); color: var(--ink, #10231f); box-shadow: 0 -10px 40px rgb(0 0 0 / .25); }
.cs-sheet::backdrop { background: rgb(6 20 18 / .45); }
@media (min-width: 761px) { .cs-sheet { margin: auto; border-radius: 20px; } }
.cs-form { display: grid; gap: 14px; padding: 16px 18px calc(16px + env(safe-area-inset-bottom)); }
.cs-form header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cs-form h2 { font: 650 1.1rem/1.3 var(--display, system-ui); margin: 0; }
.cs-sub { color: var(--muted, #667); font-size: .85rem; }
.cs-x { border: 0; background: var(--sunk, #eef); color: inherit; width: 40px; height: 40px; border-radius: 50%; font-size: 1rem; cursor: pointer; flex: none; }
.cs-input { width: 100%; font: 400 1.1rem/1.35 var(--body, system-ui); padding: 13px 14px; border: 1.5px solid var(--line, #ccd); border-radius: 12px; background: var(--bg, #fff); color: inherit; min-height: 52px; }
textarea.cs-input { resize: vertical; min-height: 120px; }
.cs-input:focus { outline: none; border-color: var(--accent, #08805a); box-shadow: 0 0 0 3px var(--accent-soft, #dff4ea); }
.cs-options { display: grid; gap: 8px; max-height: 52dvh; overflow: auto; }
.cs-opt { text-align: start; font: 500 1.02rem/1.3 var(--body, system-ui); padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--line, #ccd); background: var(--surface, #fff); color: inherit; cursor: pointer; min-height: 52px; }
.cs-opt[aria-checked="true"] { border-color: var(--accent, #08805a); background: var(--accent-soft, #dff4ea); font-weight: 650; }
.cs-check { display: flex; gap: 12px; align-items: center; font-size: 1.05rem; padding: 10px 0; }
.cs-check input { width: 26px; height: 26px; accent-color: var(--accent, #08805a); }
.cs-form footer { display: flex; gap: 10px; }
.cs-btn { flex: 1; min-height: 52px; border-radius: 14px; border: 1.5px solid var(--line, #ccd); background: var(--surface, #fff); color: inherit; font: 650 1.02rem/1 var(--display, system-ui); cursor: pointer; padding: 0 16px; }
.cs-btn.primary { background: var(--brand, #0f8f63); border-color: transparent; color: #fff; }
.cs-btn.ghost { background: none; }
.cs-btn:disabled { opacity: .45; cursor: default; }
.cs-row { display: flex; gap: 10px; }
.cs-signed { display: grid; place-items: center; background: #fff; border-radius: 12px; border: 1px solid var(--line, #ccd); padding: 14px; min-height: 110px; }
.cs-signed img { max-height: 100px; max-width: 100%; }

/* signature pad */
.cs-pad { display: grid; gap: 10px; }
.cs-tabs { display: inline-flex; background: var(--sunk, #eef); border-radius: 12px; padding: 3px; justify-self: start; }
.cs-tabs button { border: 0; background: none; color: inherit; font: 600 .95rem/1 var(--body, system-ui); padding: 10px 18px; border-radius: 9px; cursor: pointer; min-height: 40px; }
.cs-tabs button[aria-selected="true"] { background: var(--surface, #fff); box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
.cs-draw { position: relative; }
.cs-canvas { display: block; width: 100%; height: 190px; background: #fff; border: 1.5px dashed #9aa8a4; border-radius: 14px; touch-action: none; cursor: crosshair; }
.cs-canvas.small { height: 150px; }
.cs-line { position: absolute; inset-inline: 22px; bottom: 44px; border-bottom: 1.5px solid #c4cdca; pointer-events: none; }
.cs-hint { position: absolute; inset-inline: 0; bottom: 14px; text-align: center; color: #7b8784; font-size: .82rem; pointer-events: none; }
.cs-typewrap { display: grid; gap: 10px; }
.cs-typed { font: 400 1.1rem/1.3 var(--body, system-ui); padding: 13px 14px; border: 1.5px solid var(--line, #ccd); border-radius: 12px; background: var(--bg, #fff); color: inherit; }
.cs-typed-preview { min-height: 96px; display: grid; place-items: center; background: #fff; color: #0a1f4d; border: 1.5px dashed #9aa8a4; border-radius: 14px; padding: 8px 14px; overflow: hidden; white-space: nowrap; }
.cs-clear { justify-self: end; border: 0; background: none; color: var(--info, #2158c9); font: 600 .95rem/1 var(--body, system-ui); padding: 8px 4px; cursor: pointer; }

/* the bar that walks the signer through the fields */
.cbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface, #fff); border-bottom: 1px solid var(--line, #ccd); }
.cbar .grow { flex: 1; min-width: 0; }
.cbar h1, .cbar h2 { font: 650 1rem/1.25 var(--display, system-ui); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbar .prog { height: 5px; border-radius: 3px; background: var(--sunk, #e9f1ed); overflow: hidden; margin-top: 6px; }
.cbar .prog i { display: block; height: 100%; background: var(--brand, #0f8f63); transition: width .25s; }
.cbar .count { font-size: .8rem; color: var(--muted, #586a66); margin-top: 4px; }
.cbar .cs-btn { flex: none; min-height: 46px; }
.cdock { position: fixed; inset-inline: 0; bottom: 0; z-index: 6; display: flex; gap: 10px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--surface, #fff); border-top: 1px solid var(--line, #ccd); box-shadow: 0 -8px 24px -18px rgb(0 0 0 / .4); }
.cdock .cs-btn { min-height: 54px; }
@media (min-width: 761px) { .cdock { inset-inline: auto 0; left: 50%; transform: translateX(-50%); width: min(620px, 100%); border-radius: 18px 18px 0 0; border: 1px solid var(--line, #ccd); border-bottom: 0; } }

/* ---------- in the CRM ---------- */
.ct-list { display: grid; gap: 10px; }
.ct-row { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; display: grid; gap: 6px; background: var(--surface); }
.ct-row.void { opacity: .55; }
.ct-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ct-main strong { font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.ct-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ct-dlg { width: min(560px, calc(100vw - 24px)); }
.ct-dlg .dlg-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.ct-search { margin: 6px 18px 10px; width: calc(100% - 36px); padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); }
.ct-pick { display: grid; gap: 6px; padding: 0 12px 16px; max-height: 62dvh; overflow: auto; }
.ct-pick-i { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: start; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; min-height: 54px; }
.ct-pick-i:hover { border-color: var(--accent); background: var(--accent-soft); }
.ct-pick-i .sub { flex: none; }
body.ct-open { overflow: hidden; }
.ct-edit { position: fixed; inset: 0; z-index: 60; background: var(--sunk); overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.ct-top { position: sticky; top: 0; z-index: 7; display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--storm); color: #fff; }
.ct-top h1 { font-size: 1rem; line-height: 1.25; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-top .grow { flex: 1; min-width: 0; }
.ct-top .btn { background: rgb(255 255 255 / .12); color: #fff; border-color: transparent; }
.ct-steps { display: flex; gap: 14px; list-style: none; margin: 6px 0 0; padding: 0; font-size: .8rem; opacity: .9; flex-wrap: wrap; }
.ct-steps li { display: flex; align-items: center; gap: 6px; opacity: .6; }
.ct-steps li.on, .ct-steps li.done { opacity: 1; }
.ct-steps b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgb(255 255 255 / .18); font-size: .72rem; }
.ct-steps li.on b { background: var(--mint); color: var(--storm); }
.ct-body { max-width: 760px; margin: 0 auto; padding: 18px 16px 130px; display: grid; gap: 14px; }
.ct-form { display: grid; gap: 14px; }
.ct-group { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 14px 16px 16px; margin: 0; display: grid; gap: 12px; min-width: 0; }
.ct-group legend { font: 650 .95rem/1 var(--display); padding: 0 6px; }
.ct-f input, .ct-f select, .ct-f textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1rem; }
.ct-f textarea { min-height: 92px; resize: vertical; }
.ct-f > span { color: var(--ink); font-weight: 550; font-size: .88rem; text-align: start; }
.ct-f .req { color: var(--bad); }
.ct-f .ct-n { font-style: normal; color: var(--muted); font-weight: 500; margin-inline-end: 8px; }
.ct-f.bad input, .ct-f.bad select, .ct-f.bad textarea, .ct-f.bad .seg { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); border-radius: 12px; }
.ct-f .seg { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-f .seg button { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 550; }
.ct-f .seg button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.ct-edit .cbar { top: 0; }
@media (max-width: 760px) { .ct-steps li:not(.on) span { display: none; } .ct-steps { gap: 8px; flex-wrap: nowrap; } }
.ct-doc { padding: 0 10px; }
.ct-edit > .err { position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); inset-inline: 16px; z-index: 8; margin: 0; background: var(--bad-bg); padding: 10px 14px; border-radius: 12px; }
.ct-edit > .err:empty { display: none; }
.ct-done { text-align: center; justify-items: center; padding-top: 40px; }
.ct-ok { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: var(--accent-soft); color: var(--accent); }
.ct-choices { display: grid; gap: 10px; width: 100%; max-width: 460px; }
.ct-choice { display: grid; gap: 4px; text-align: start; padding: 16px 18px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; min-height: 64px; }
.ct-choice strong { font: 650 1.05rem/1.2 var(--display); }
.ct-choice span { color: var(--muted); font-size: .88rem; }
.ct-choice.primary { background: var(--brand); border-color: transparent; color: #fff; }
.ct-choice.primary span { color: rgb(255 255 255 / .8); }
.ct-choice:disabled { opacity: .6; cursor: progress; }
.ct-note { margin: 0; min-height: 1.4em; font-weight: 600; color: var(--muted); }
.ct-note.ok { color: var(--ok); }
.ct-note.bad { color: var(--bad); }
.ct-link { width: 100%; max-width: 460px; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: .9rem; }
/* messages show above the contract screen */
body.ct-open .toast { z-index: 90; }

/* ---------- contracts page ---------- */
.tile.on { border-color: var(--accent); }
.ctp-wrap { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.ctp { width: 100%; border-collapse: collapse; }
.ctp th { text-align: start; font-size: .78rem; font-weight: 600; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ctp td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
.ctp tr:last-child td { border-bottom: 0; }
.ctp-row { cursor: pointer; }
.ctp-row:hover td { background: var(--sunk); }
.ctp-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ctp-row.void td { opacity: .55; }
.ctp-row strong { font-weight: 600; overflow-wrap: anywhere; }
.ctp-signers div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ctp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.ctp-dot.ok { background: var(--ok); }
.ctp-acts .row { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ctp-empty { padding: 30px 0; text-align: center; }
@media (max-width: 760px) {
  .ctp-tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .ctp-tabs button { white-space: nowrap; flex: none; }
  .ctp thead { display: none; }
  .ctp, .ctp tbody, .ctp tr, .ctp td { display: block; width: 100%; }
  .ctp tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .ctp td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; }
  .ctp td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; padding-top: 2px; }
  .ctp td:first-child { display: block; font-size: 1rem; padding-bottom: 6px; }
  .ctp td:first-child::before, .ctp td.ctp-acts::before { content: none; }
  .ctp td.ctp-acts { display: block; padding-top: 8px; }
  .ctp-acts .row { justify-content: flex-start; }
}

/* ---------- the actions menu (⋯) ---------- */
.cta-btn { padding-inline: 8px; }
.cta-btn[aria-expanded="true"] { background: var(--sunk); }
.cta-menu { position: fixed; z-index: 120; min-width: 210px; max-height: calc(100vh - 16px); overflow-y: auto; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 36px rgb(0 0 0 / .18); padding: 6px; display: flex; flex-direction: column; }
.cta-menu button { all: unset; box-sizing: border-box; padding: 9px 12px; border-radius: 6px; font-size: .92rem; cursor: pointer; text-align: start; }
.cta-menu button:hover, .cta-menu button:focus-visible { background: var(--sunk); }
.cta-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cta-menu button.bad { color: var(--bad); }
.cta-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.cta-dlg { width: min(520px, calc(100vw - 32px)); }
.cta-body { padding: 4px 18px 8px; display: grid; gap: 10px; max-height: 65vh; overflow-y: auto; }
.cta-body p { margin: 0; }
.cta-btns { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px 16px; }
.cta-hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.cta-hist li { padding: 9px 0 9px 0; border-bottom: 1px solid var(--line); padding-inline-start: 14px; position: relative; }
.cta-hist li::before { content: ""; position: absolute; inset-inline-start: 0; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.cta-hist li:last-child { border-bottom: 0; }
.cta-name { font-weight: 600; }
.cta-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.cta-kv dt { color: var(--muted); font-size: .85rem; }
.cta-kv dd { margin: 0; overflow-wrap: anywhere; }
.cta-lab { display: grid; gap: 6px; }
.cta-num { width: 120px; }
.cta-legal { font-size: .9rem; line-height: 1.5; color: var(--ink); }
.cta-print { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; inset-inline-start: -10px; top: 0; }
.chip.zoho { background: var(--sunk); color: var(--muted); }
