@font-face { font-family: 'Sig'; src: url('../vendor/sig.woff2') format('woff2'); font-display: block; }
:root {
  --bg: #f4f5f7; --card: #fff; --ink: #16181d; --muted: #646b78; --line: #e2e5ea; --brand: #1f3fbf; --brand-ink: #fff;
  --ok: #0f8a4b; --warn: #b26a00; --bad: #c62828; --field: #ffd84d; --radius: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }
.btn { appearance: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 11px 16px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); min-height: 44px; }
.btn:hover { background: #f7f8fa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.big { width: 100%; padding: 15px; font-size: 1.05rem; }
.btn.slim { min-height: 36px; padding: 7px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=tel], input[type=password], textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; min-height: 44px; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
label.lbl { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #eef0f4; color: var(--muted); white-space: nowrap; }
.pill.ok { background: #e3f5ea; color: var(--ok); }
.pill.warn { background: #fff3dc; color: var(--warn); }
.pill.bad { background: #fde8e8; color: var(--bad); }
.pill.blue { background: #e6edff; color: var(--brand); }
.err { color: var(--bad); font-weight: 600; }
.hidden { display: none !important; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .wrap { padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.logo { font-weight: 800; letter-spacing: -.02em; font-size: 1.1rem; }
.logo span { color: var(--brand); }

/* pages */
.pages { display: flex; flex-direction: column; gap: 30px; padding-bottom: 22px; align-items: center; }
.page { position: relative; width: 100%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 4px 14px rgba(0,0,0,.06); border-radius: 3px; }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 3px; }
.page .layer { position: absolute; inset: 0; }
.page .pno { position: absolute; right: 8px; bottom: -20px; font-size: .75rem; color: var(--muted); }

/* fields */
.field { position: absolute; border-radius: 4px; display: flex; align-items: center; justify-content: center; overflow: visible;
  font-size: 12px; font-weight: 700; user-select: none; -webkit-user-select: none; }
.field .ftxt { pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; max-width: 100%; }

/* editor */
.edit .field { border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); touch-action: none; cursor: move; }
.edit .field.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent); }
.edit .field .del, .edit .field .rsz { display: none; position: absolute; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff;
  align-items: center; justify-content: center; font-size: 15px; line-height: 1; border: 2px solid #fff; }
.edit .field.sel .del, .edit .field.sel .rsz { display: flex; }
.edit .field .del { top: -14px; right: -14px; cursor: pointer; }
.edit .field .rsz { bottom: -14px; right: -14px; cursor: nwse-resize; touch-action: none; }
.edit.placing .layer { cursor: crosshair; }
.tools { position: sticky; top: 57px; z-index: 15; background: var(--bg); padding: 8px 0; }
.tools .scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tool { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 600; cursor: pointer; min-height: 40px; font-size: .9rem; }
.tool.on { background: var(--c, var(--brand)); color: #fff; border-color: var(--c, var(--brand)); }
.chip { flex: none; border: 2px solid var(--c); color: var(--c); background: #fff; border-radius: 99px; padding: 5px 12px; font-weight: 700; cursor: pointer; font-size: .85rem; }
.chip.on { background: var(--c); color: #fff; }
.hint { background: #fffbe6; border: 1px solid #f3e2a0; border-radius: 10px; padding: 9px 12px; font-size: .9rem; margin-top: 8px; }
.signer-row { display: grid; grid-template-columns: 14px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.signer-row:first-child { border-top: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); margin-top: 15px; }
.signer-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.signer-fields .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .signer-fields { grid-template-columns: 1fr; } }

/* list */
.doc { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.doc:first-child { border-top: 0; }
.doc .t { font-weight: 700; }

/* signing */
.sign .field { border: 2px dashed #c79a00; background: color-mix(in srgb, var(--field) 55%, transparent); color: #5c4700; cursor: pointer; touch-action: manipulation; }
.sign .field.done { border: 1px solid transparent; background: rgba(31,79,216,.04); }
.sign .field.done:hover { border-color: rgba(31,79,216,.3); }
.sign .field.pulse { animation: pulse 1s ease 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(255,190,0,.45); } }
.sign .field img { width: 100%; height: 100%; object-fit: contain; object-position: left center; pointer-events: none; }
.sign .field.initials img { object-position: center; }
.sign .field input.fin { width: 100%; height: 100%; border: 0; background: transparent; padding: 0 3px; font-weight: 500; color: #0d1a59; min-height: 0; border-radius: 0; }
.sign .field input.fin:focus { outline: 2px solid var(--brand); }
.sign .field .val { font-weight: 500; color: #0d1a59; white-space: nowrap; padding: 0 3px; width: 100%; text-align: left; }
.sign .field.checkbox .val { text-align: center; font-size: 1.2em; }
.sign .field .opt { position: absolute; top: -16px; left: 0; font-size: 10px; color: #8a6d00; font-weight: 600; }
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.bottombar .inner { max-width: 860px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.spacer { height: 90px; }

/* sheet (signature pad) */
.sheet-bg { position: fixed; inset: 0; background: rgba(10,12,20,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 640px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 100vh; overflow: auto; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 16px; } }
.tabs { display: flex; background: #eef0f4; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.pad { position: relative; border: 1px solid var(--line); border-radius: 10px; background: #fff; height: 190px; touch-action: none; }
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pad .base { position: absolute; left: 18px; right: 18px; bottom: 44px; border-bottom: 1.5px solid #c9ced8; pointer-events: none; }
.pad .x { position: absolute; left: 20px; bottom: 50px; color: #9aa1ae; font-size: 20px; pointer-events: none; }
.pad .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #b3b9c4; pointer-events: none; font-weight: 600; }
.typed { font-family: 'Sig', cursive; font-size: 46px; color: #0d1a59; height: 110px; display: flex; align-items: center; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; overflow: hidden; white-space: nowrap; }
.legal { font-size: .8rem; color: var(--muted); }
.qr { display: flex; justify-content: center; padding: 8px; }
.qr svg, .qr img { width: 220px; height: 220px; }
.log { font-size: .85rem; }
.log div { padding: 5px 0; border-top: 1px solid var(--line); }
.log div:first-child { border-top: 0; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: #16181d; color: #fff; padding: 10px 16px; border-radius: 10px;
  z-index: 60; font-weight: 600; font-size: .92rem; max-width: 90vw; }
.center { text-align: center; }
.check { width: 64px; height: 64px; border-radius: 50%; background: #e3f5ea; color: var(--ok); display: flex; align-items: center; justify-content: center;
  font-size: 34px; margin: 6px auto 12px; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.consent input { width: 22px; height: 22px; flex: none; margin-top: 1px; }

/* signer: 3 typed styles, text sized to the box */
@font-face { font-family: 'Sig2'; src: url('../vendor/sig2.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'Sig3'; src: url('../vendor/sig3.woff2') format('woff2'); font-display: block; }
.sign .field { container-type: size; }
.sign .field .c { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; }
.sign .field .val, .sign .field input.fin { font-size: 60cqh; }
.sign .field.checkbox .val { font-size: 80cqh; padding: 0; }
.sign .field .ftxt { font-size: min(12px, 45cqh); }
.styles { display: grid; gap: 8px; }
.style { height: 78px; font-size: 40px; text-align: left; white-space: nowrap; overflow: hidden; padding: 0 14px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: #0d1a59; cursor: pointer; }
.style.on { border: 2px solid var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.linkbtn { background: none; border: 0; padding: 6px; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .9rem; }
/* settings: events x channels grid */
.gridwrap { overflow-x: auto; }
.grid { border-collapse: collapse; width: 100%; font-size: .92rem; }
.grid th, .grid td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.grid tbody th { text-align: left; font-weight: 600; }
.grid thead th { font-size: .8rem; color: var(--muted); }
.grid thead th.off { opacity: .5; }
.grid input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--brand); }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
