:root {
  --bg: #eef0f3; --panel: #fff; --ink: #111418; --muted: #6b7280; --line: #d9dde3;
  --brand: #111; --gold: #f2b705; --gold-ink: #111; --blue: #1d4ed8; --fill: #12307a;
  --staff: #e8f0ff; --staff-b: #7aa2f7; --client: #fff6d6; --client-b: #e0b100;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--blue); }
button { font: inherit; cursor: pointer; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 6px; font-weight: 600; }
.btn:hover { border-color: #b8bec8; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.primary:hover { filter: brightness(.96); }
.btn.dark { background: #111; color: #fff; border-color: #111; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input.in, select.in, textarea.in { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
input.in:focus, textarea.in:focus { outline: 2px solid #f2b70566; border-color: var(--gold); }
label.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .04em; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: #111; color: #fff; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .08em; font-size: 15px; color: #fff; text-decoration: none; }
.topbar .brand img { height: 26px; filter: invert(1); }
.topbar .brand small { font-weight: 500; letter-spacing: 0; color: #9ca3af; font-size: 12px; }
.topbar .grow { flex: 1; min-width: 0; }
.topbar .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .prog { color: #d1d5db; font-size: 13px; white-space: nowrap; }
.topbar .btn { border-color: #333; }
@media (max-width: 640px) { .topbar { padding: 8px 10px; gap: 8px; } .topbar .brand small, .topbar .prog .long { display: none; } .topbar .title { font-size: 13px; } }

/* dashboard */
.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 16px 60px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 22px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.tabs button.on { background: #111; color: #fff; border-color: #111; }
.tabs button .n { color: var(--muted); font-weight: 500; margin-left: 4px; }
.tabs button.on .n { color: #bbb; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 14px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.row:hover td { background: #fafbfc; }
.who b { display: block; }
.who span { color: var(--muted); font-size: 12.5px; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.staff { background: #fff1c2; color: #7a5600; }
.pill.client { background: #dbeafe; color: #1e40af; }
.pill.completed { background: #dcfce7; color: #166534; }
.pill.voided { background: #f3f4f6; color: #6b7280; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
@media (max-width: 760px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.list td { border: 0; padding: 4px 14px; }
  .acts { justify-content: flex-start; }
}

/* modal */
.modal-bg { position: fixed; inset: 0; background: #0008; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; padding: 22px; box-shadow: 0 20px 60px #0005; }
.modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal .sub { color: var(--muted); margin: 0 0 12px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.tpls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tpl { border: 2px solid var(--line); border-radius: 10px; padding: 12px; text-align: left; background: #fff; }
.tpl b { display: block; font-size: 15px; margin-bottom: 3px; }
.tpl span { color: var(--muted); font-size: 12.5px; line-height: 1.35; display: block; }
.tpl.on { border-color: var(--gold); background: #fffbea; }
@media (max-width: 560px) { .tpls { grid-template-columns: 1fr; } }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.err { color: var(--bad); font-weight: 600; margin-top: 10px; min-height: 1em; }
.copybox { display: flex; gap: 6px; }
.copybox input { flex: 1; font-size: 12.5px; }
.events { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.events li { padding: 7px 0; border-bottom: 1px solid #f0f1f3; }
.events li span { color: var(--muted); font-size: 12px; display: block; }

/* ===== document ===== */
.docwrap { padding: 22px 12px 120px; }
.page { position: relative; width: 816px; max-width: 100%; margin: 0 auto 22px; background: #fff; box-shadow: 0 1px 3px #0002, 0 6px 24px #0000000f; padding: 34px 64px 54px; font: 13.6px/1.42 Arial, Helvetica, sans-serif; color: #000; }
.page .plogo { display: block; margin: 0 auto 6px; height: 60px; }
.page .pnum { position: absolute; right: 64px; bottom: 18px; font-size: 12px; color: #444; }
.page p { margin: 0 0 11px; }
.page h2 { font-size: 15px; margin: 8px 0 10px; }
.page h3 { font-size: 14px; margin: 14px 0 9px; }
.page h4 { font-size: 13.6px; margin: 12px 0 3px; }
.page ul { margin: 0 0 8px; padding-left: 40px; }
.page ol { margin: 4px 0 8px; padding-left: 28px; }
.page .center { text-align: center; }
.page .u { text-decoration: underline; }
.page .muted { color: #333; }
.page .small { font-size: 11.5px; line-height: 1.35; }
.page .effective { text-align: right; margin-bottom: 14px; }
.page .namefill { margin: 6px 0 18px; }
.page table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 12px; }
.page th { background: #d6d6d6; border: 1px solid #000; padding: 3px 6px; font-size: 12px; }
.page th.big { font-size: 14px; }
.page td { border: 1px solid #000; padding: 5px 6px; vertical-align: top; font-weight: 700; }
.page td.box { width: 38px; text-align: center; vertical-align: middle; }
.page table.terms td:nth-child(2), .page table.terms td:nth-child(4) { width: 34%; }
.page table.fees td.lbl { text-align: right; width: 53%; }
.page table.fees td.amt { width: 14%; white-space: nowrap; }
.page table.fees td.top { vertical-align: top; }
.page table.payauth td { font-weight: 400; height: 44px; }
.page table.payauth td b { font-weight: 700; }
.page table.participants td { height: 30px; font-weight: 400; }
.page table.participants th { font-weight: 700; }
.page table.participants th.spacer { height: 22px; }
.page table.pkg td.k { background: #d6d6d6; width: 13%; }
.page table.pkg td { font-weight: 400; }
.page .rules, .page .waiver { font-size: 10.6px; line-height: 1.33; }
.page .rules p, .page .waiver p { margin: 0 0 7px; }
.page .lines { font-size: 11.5px; }
.page .lines > div { margin: 8px 0; }
.page .minor { font-size: 11.5px; margin-top: 10px; }
.page .inits { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-top: 18px; font-size: 13.6px; }
.page .inits span { display: flex; align-items: center; gap: 6px; }
.page .footsig { margin-top: 18px; font-size: 15px; }
.page .footsig > div { display: flex; align-items: flex-end; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.page .footsig .lbl { white-space: nowrap; }
.page .sigblock { margin-top: 24px; }
.page .sigtitle { font-weight: 700; margin: 18px 0 6px; }
.page .sigrow { display: grid; grid-template-columns: 1.3fr .8fr 1.3fr; gap: 16px; }
.page .sigrow > div { display: flex; flex-direction: column; justify-content: flex-end; min-height: 58px; }
.page .sigrow .f-val, .page .sigrow .f-blank, .page .sigrow .f-auto { border-bottom: 0; }
.page .sigrow .f-sig, .page .sigrow .f-tag, .page .sigrow .f-wait { align-self: flex-start; }
.page .sigrow > div > span:last-child { border-top: 1px solid #000; font-size: 12px; padding-top: 2px; }
.page label.ct { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; white-space: nowrap; }

/* fields */
.f { display: inline-block; vertical-align: middle; }
.f-in { font: 13px Arial, Helvetica, sans-serif; color: var(--fill); border: 1px solid; border-radius: 3px; padding: 3px 5px; max-width: 100%; height: 26px; }
textarea.f-in { height: 64px; width: 100%; display: block; resize: vertical; }
.f-in.staff { background: var(--staff); border-color: var(--staff-b); }
.f-in.client { background: var(--client); border-color: var(--client-b); }
.f-in.req { border-width: 2px; }
.f-in.need { box-shadow: 0 0 0 3px #ef444455; border-color: #ef4444; }
.f-in.ok { border-width: 1px; }
.f-val { color: var(--fill); font-weight: 400; border-bottom: 1px solid #000; padding: 0 3px; min-width: 40px; display: inline-block; white-space: pre-wrap; }
.f-val.plain { border-bottom: 0; }
.f-blank { display: inline-block; min-width: 60px; height: 20px; border-bottom: 1px solid #000; vertical-align: bottom; }
.f-wait { display: inline-block; min-height: 22px; border: 1px dashed #9ca3af; border-radius: 3px; background: repeating-linear-gradient(135deg, #f8f8f8, #f8f8f8 6px, #f1f1f1 6px, #f1f1f1 12px); color: #6b7280; font: 600 10px Arial; padding: 4px 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .03em; }
.f-chk { display: inline-block; width: 17px; height: 17px; border: 1.5px solid #000; border-radius: 2px; position: relative; vertical-align: middle; background: #fff; }
.f-chk.on::after { content: ""; position: absolute; left: 4.5px; top: 0.5px; width: 5px; height: 10px; border: solid var(--fill); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
input.f-cb { width: 19px; height: 19px; margin: 0; vertical-align: middle; cursor: pointer; }
input.f-cb.staff { accent-color: #2563eb; outline: 2px solid var(--staff-b); outline-offset: 1px; }
input.f-cb.client { accent-color: #b58900; outline: 2px solid var(--client-b); outline-offset: 1px; }
.f-tag { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; border: 2px solid #e0b100; background: #ffd84d; color: #3d2f00; font: 700 11px Arial; border-radius: 4px; padding: 4px 10px; min-width: 72px; height: 40px; cursor: pointer; vertical-align: middle; }
.f-tag.staff { border-color: #3b6fe0; background: #b9d0ff; color: #0b2a6b; }
.f-tag .ar { font-size: 14px; line-height: 1; }
.f-tag.init { min-width: 52px; height: 38px; padding: 3px 6px; }
.f-tag.need { box-shadow: 0 0 0 3px #ef444466; }
.f-sig { display: inline-block; vertical-align: bottom; position: relative; }
.f-sig img { height: 44px; display: block; }
.f-sig.init img { height: 30px; }
.f-sig.mine { cursor: pointer; outline: 1px dashed #9ca3af; outline-offset: 2px; }
.f-sig .sid { position: absolute; left: 0; bottom: -10px; font: 8px Arial; color: #1f3a8a; white-space: nowrap; }
.f-auto { color: #9ca3af; font: italic 12px Arial; border-bottom: 1px dotted #9ca3af; padding: 0 3px; }
.page .footsig .f-sig img { height: 38px; }
.page .footsig .f-blank { min-width: 200px; }

@media screen and (max-width: 860px) {
  .docwrap { padding: 10px 0 120px; }
  .page { padding: 22px 16px 46px; margin-bottom: 10px; box-shadow: none; border-top: 1px solid var(--line); }
  .page .pnum { right: 16px; }
  .page .plogo { height: 46px; }
  .page table { font-size: 11px; }
  .page td { padding: 4px; }
  .page td.box { width: 30px; }
  .page .sigrow { grid-template-columns: 1fr; }
  .page .footsig { font-size: 13px; }
  .f-in { font-size: 16px; height: 32px; } /* no iOS zoom */
  textarea.f-in { font-size: 16px; }
}

/* signing UI */
.nextbtn { position: fixed; z-index: 30; right: 18px; bottom: 18px; }
.nextbtn .btn { box-shadow: 0 6px 20px #0004; padding: 12px 20px; font-size: 15px; }
.banner { max-width: 816px; margin: 0 auto 14px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--gold); border-radius: 8px; padding: 14px 16px; }
.banner.ok { border-left-color: var(--ok); }
.banner h3 { margin: 0 0 4px; font-size: 16px; }
.banner p { margin: 0; color: #374151; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 4px; border: 1px solid; }
.adopt-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 12px; }
.adopt-tabs button { border: 0; background: none; padding: 8px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }
.adopt-tabs button.on { color: var(--ink); border-color: var(--gold); }
.styles { display: grid; gap: 8px; }
.style-opt { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: 8px; padding: 6px 12px; background: #fff; text-align: left; }
.style-opt.on { border-color: var(--gold); background: #fffbea; }
.style-opt .s { font-size: 30px; color: #0b1f55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.style-opt .i { font-size: 26px; color: #0b1f55; border-left: 1px solid var(--line); padding-left: 10px; }
.pad { border: 1px dashed #9ca3af; border-radius: 8px; background: #fcfcfd; touch-action: none; width: 100%; display: block; }
.padrow { display: grid; grid-template-columns: 3fr 1.3fr; gap: 10px; }
.padrow .cap { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.consent { font-size: 13px; color: #374151; display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; }
.consent input { margin-top: 3px; width: 17px; height: 17px; }
.doneview { max-width: 560px; margin: 50px auto; text-align: center; background: #fff; border-radius: 12px; padding: 30px 24px; border: 1px solid var(--line); }
.doneview .big { font-size: 46px; }
.doneview h2 { margin: 6px 0 8px; }
.doneview p { color: #374151; }
.doneview .copybox { margin: 14px 0; }

/* certificate */
.cert h2 { font-size: 18px; margin: 4px 0 12px; }
.cert table td, .cert table th { font-weight: 400; text-align: left; font-size: 11.5px; }
.cert table th { font-weight: 700; }
.cert .sigimg { height: 32px; }
.cert .mono { font-family: Consolas, Menlo, monospace; font-size: 11px; word-break: break-all; }

/* print / pdf */
@media print {
  html, body { background: #fff; }
  .topbar, .nextbtn, .banner, .noprint { display: none !important; }
  .docwrap { padding: 0; }
  .page { width: auto; max-width: none; margin: 0; box-shadow: none; padding: 0 0 26px; break-after: page; border: 0; }
  .page:last-child { break-after: auto; }
  .page .pnum { right: 0; bottom: 0; }
}
body.print { background: #fff; }
body.print .page { width: auto; margin: 0; box-shadow: none; padding: 0 0 30px; break-after: page; min-height: 9.9in; }
body.print .page:last-child { break-after: auto; }
body.print .page .pnum { right: 0; bottom: 0; }
body.print .docwrap { padding: 0; }
/* tighter type for paper so each template page stays one sheet */
@media print {
  .page { font-size: 12.6px; line-height: 1.36; }
  .page .plogo { height: 50px; margin-bottom: 4px; }
  .page p { margin-bottom: 8px; }
  .page td { padding: 3px 5px; }
  .page th { padding: 2px 5px; }
  .page .inits { margin-top: 10px; }
  .page .rules, .page .waiver { font-size: 10.2px; line-height: 1.3; }
  .page table.payauth td { height: 38px; }
  .page .footsig { margin-top: 10px; font-size: 14px; }
}
