[hidden] { display: none !important; }
/* The typed-signature font, served from here so no third party sees the signer. */
@font-face { font-family: "Dancing Script"; font-style: normal; font-weight: 600; font-display: swap; src: url("../vendor/fonts/dancing-script-latin-600-normal.woff2") format("woff2"); }

/* The signing page and the admin UI. Plain CSS, so the server needs no Node build. */
:root {
    --brand: #0f4c81;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f5f6f8;
    --card: #ffffff;
    --ok: #166534;
    --ok-bg: #dcfce7;
    --bad: #991b1b;
    --bad-bg: #fee2e2;
    --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; margin: 0 0 1rem; }
code, .mono { font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hash { word-break: break-all; }

/* ---- Brand bar ---- */
.brandbar { background: var(--brand); color: #fff; }
.brandbar-inner { max-width: 960px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-logo { max-height: 36px; max-width: 220px; background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-secure { font-size: .85rem; opacity: .85; }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 40px; }
.page-foot { max-width: 960px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: .8rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.intro { margin-bottom: 16px; }

/* ---- Viewer ---- */
.viewer { margin-bottom: 20px; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: #fff; font-size: .9rem; }
.viewer-bar .link, .viewer-bar a { color: #fff; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 12px; }
.pages canvas.page { background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.35); max-width: 100%; height: auto; }

/* ---- Forms ---- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
    width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; margin: 12px 0 4px; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }

.btn { display: inline-block; font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn-danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-small { padding: 6px 12px; font-size: .9rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.notice { border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; background: #eef2ff; }
.notice p { margin: 0; }
.notice-error { background: var(--bad-bg); color: var(--bad); }
.notice-ok { background: var(--ok-bg); color: var(--ok); }

/* ---- Signature pad ---- */
.pad { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; background: #fafafa; }
.pad-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.pad-tab { font: inherit; padding: 6px 14px; border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; cursor: pointer; }
.pad-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pad-canvas { display: block; width: 100%; max-width: 600px; aspect-ratio: 900 / 260; background: #fff; border: 1px dashed #94a3b8; border-radius: 8px; touch-action: none; }
.pad-small .pad-canvas { max-width: 240px; aspect-ratio: 2 / 1; }
.pad-canvas.is-drawing { cursor: crosshair; border-style: solid; }
.pad-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; max-width: 600px; }
.pad-hint { color: var(--muted); font-size: .85rem; }

.terms { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; font-size: .92rem; }
.terms ul { padding-left: 1.2rem; margin: .4rem 0 .6rem; }
.terms li { margin-bottom: .3rem; }

.decline summary { cursor: pointer; font-weight: 600; color: #b91c1c; }
.decline form { margin-top: 14px; }

.state h1 { margin-bottom: .2rem; }

/* ---- Admin ---- */
.admin .brandbar { background: #111827; }
.admin-nav { display: flex; gap: 16px; align-items: center; }
.admin-nav a { color: #fff; text-decoration: none; opacity: .85; }
.admin-nav a:hover, .admin-nav a.is-active { opacity: 1; text-decoration: underline; }
.admin .wrap { max-width: 1180px; }
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; background: #f1f5f9; font-size: .8rem; }
.pill-completed, .pill-delivered, .pill-signed { background: var(--ok-bg); color: var(--ok); }
.pill-declined, .pill-withdrawn, .pill-expired, .pill-failed { background: var(--bad-bg); color: var(--bad); }
.pill-pending, .pill-sent, .pill-viewed, .pill-rendering { background: #fef3c7; color: #92400e; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.editor { font-family: Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.45; min-height: 420px; }
.keybox { font-family: Menlo, Consolas, monospace; background: #111827; color: #a7f3d0; padding: 12px; border-radius: 8px; word-break: break-all; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
dl.facts { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

@media (max-width: 720px) {
    .grid-2 { grid-template-columns: 1fr; }
    dl.facts { grid-template-columns: 1fr; }
    .brand-secure { display: none; }
    .pages { max-height: none; }
}

/* ---- Fields drawn on the document ---- */
.hl { background: #dcfce7; border: 1px solid #16a34a; padding: 0 4px; border-radius: 3px; }
.page-wrap { position: relative; background: #fff; border: 2px solid var(--brand); border-radius: 0; box-sizing: content-box; }
.page-wrap canvas.page { box-shadow: none; display: block; }
.doc-field { position: absolute; display: flex; align-items: center; justify-content: flex-start; padding: 0 4px; border-radius: 3px; font: 600 11px/1.1 "Helvetica Neue", Helvetica, Arial, sans-serif; overflow: hidden; }
.doc-field.is-mine { background: rgba(220, 252, 231, .9); border: 1.5px solid #16a34a; color: #14532d; cursor: pointer; }
.doc-field.is-mine:hover, .doc-field.is-mine:focus-visible, .doc-field.is-mine:focus-within { background: rgba(187, 247, 208, .95); outline: 2px solid #15803d; outline-offset: 1px; }
.doc-field.is-mine.is-done { background: rgba(255, 255, 255, .6); border: 1px solid #86efac; color: #111827; }
.doc-field.is-mine.is-auto { background: rgba(241, 245, 249, .85); border: 1px dashed #94a3b8; color: #334155; cursor: default; font-weight: 400; }
.doc-field.is-other { background: rgba(241, 245, 249, .6); border: 1px dashed #cbd5e1; color: #94a3b8; font-weight: 400; font-size: 9px; }
.doc-field img { width: 100%; height: 100%; object-fit: contain; object-position: left bottom; display: block; }
.doc-field--sign, .doc-field--initials { align-items: flex-end; padding-bottom: 0; }
.doc-field--date { font-weight: 400; }
.doc-field .field-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-field.pulse { animation: esign-pulse 1.1s ease-out 2; }
@keyframes esign-pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .8); } 100% { box-shadow: 0 0 0 14px rgba(22, 163, 74, 0); } }
/* A text field is an input sitting on the line, in the document's typeface and size. */
.doc-field--text { padding: 0; cursor: text; }
.doc-field--text input { width: 100%; height: 100%; border: 0; margin: 0; padding: 0 3px; background: transparent; color: #111827; font-family: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif; font-weight: 400; }
.doc-field--text input:focus { outline: none; }
.doc-field--text input::placeholder { color: #15803d; opacity: .75; }
.doc-field--text.is-mine.is-done { background: rgba(255, 255, 255, .95); }

/* ---- Guide bar ---- */
.guide { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.guide-actions { display: flex; gap: 8px; }
#guide-progress { font-weight: 600; }

/* ---- Field list ---- */
.field-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.field-row.is-done span::before { content: "✓ "; color: #16a34a; font-weight: 700; }

/* ---- Popups ---- */
dialog.modal { border: 0; border-radius: 14px; padding: 22px; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(15, 23, 42, .35); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .5); }
dialog.modal .pad { margin-bottom: 8px; }
/* "Next" beside a text field on the document */
.doc-next { position: absolute; z-index: 2; display: flex; align-items: center; padding: 0 10px; border: 0; border-radius: 4px; background: #15803d; color: #fff; font: 600 12px/1 "Helvetica Neue", Helvetica, Arial, sans-serif; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.doc-next:hover { background: #166534; }
#finish-open.pulse { animation: esign-pulse 1.1s ease-out 2; }

/* ---- Signing page, simplified ---- */
.doc-title { font-size: 1.35rem; margin: 0 0 12px; }
.btn-go { background: #16a34a; border-color: #16a34a; color: #fff; min-width: 150px; padding: 11px 28px; font-size: 1rem; }
.btn-go:hover { background: #15803d; border-color: #15803d; }
.btn-go[disabled] { opacity: .7; }
.btn-go.pulse { animation: esign-pulse 1.1s ease-out 2; }
.guide #guide-progress .link { font-weight: 600; }
.decline-line { text-align: center; margin: 8px 0 24px; }
.decline-line .link { color: #6b7280; font-size: .9rem; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; line-height: 1; color: #6b7280; cursor: pointer; }
.modal-x:hover { color: #111827; }
dialog.modal { position: fixed; }
dialog.modal h2 { padding-right: 30px; }.state .actions .btn { min-width: 150px; text-align: center; padding: 11px 28px; font-size: 1rem; }
