/* Layout: one calm column like a counter clerk walking you through a paper form, step by step, with the official box grid echoed under every field. */
:root {
  --paper: #f3f5f8;
  --card: #ffffff;
  --ink: #15233a;
  --muted: #5a6577;
  --line: #d6dce5;
  --navy: #1f3d70;
  --navy-ink: #ffffff;
  --marigold: #c97a12;
  --marigold-soft: #fbf0df;
  --ok: #2c7a4b;
  --err: #b42318;
  --err-soft: #fdecea;
  --box: #fbfcfe;
  --font-body: "Hind Siliguri", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1420; --card: #161f2e; --ink: #e6ebf3; --muted: #9ba7b9; --line: #2b374a;
    --navy: #8db2f0; --navy-ink: #0e1420; --marigold: #f0a640; --marigold-soft: #2c2214;
    --ok: #5cc48a; --err: #ff8a80; --err-soft: #3a1b1a; --box: #111a27; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1420; --card: #161f2e; --ink: #e6ebf3; --muted: #9ba7b9; --line: #2b374a;
  --navy: #8db2f0; --navy-ink: #0e1420; --marigold: #f0a640; --marigold-soft: #2c2214;
  --ok: #5cc48a; --err: #ff8a80; --err-soft: #3a1b1a; --box: #111a27; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5; }
.wrap { max-width: 760px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 120px; }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

.masthead { display: flex; flex-direction: column; gap: 6px; padding-block: 8px 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.78rem; color: var(--navy); }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--navy); color: var(--navy-ink); display: grid; place-items: center; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0; }
.fee { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 0.95rem; }
.fee b { font-family: var(--font-mono); font-weight: 600; }
.notice { background: var(--marigold-soft); border: 1px solid color-mix(in srgb, var(--marigold) 35%, transparent); border-radius: var(--r); padding: 10px 14px; font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }

.section { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.types { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; }
@media (max-width: 520px) {
  .types { grid-template-columns: 1fr; gap: 8px; }
  .type:disabled { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 8px 12px; }
  .type:disabled h3 { font-size: 0.9rem; font-weight: 600; }
  .type:disabled .tag { font-size: 0.68rem; }
}
.type { text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; color: inherit; font: inherit; min-width: 0; }
.type[aria-pressed="true"] { border-color: var(--navy); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy) 18%, transparent); }
.type:disabled { cursor: not-allowed; opacity: 0.62; }
.type .code { font-family: var(--font-mono); font-size: 0.8rem; color: var(--navy); font-weight: 600; letter-spacing: 0.02em; }
.type .tag { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--marigold); font-weight: 600; }

.steps { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.step-chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 0.85rem; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.step-chip .n { font-family: var(--font-mono); font-size: 0.75rem; }
.step-chip[aria-current="step"] { background: var(--navy); border-color: var(--navy); color: var(--navy-ink); }
.step-chip.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.step-chip.skip { opacity: 0.55; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.panel-head { display: flex; flex-direction: column; gap: 4px; }
.group { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; border-top: 1px dashed var(--line); }
.group:first-of-type { border-top: 0; padding-top: 0; }
.group-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.group-title .sr { font-family: var(--font-mono); color: var(--navy); letter-spacing: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
label, .label { font-weight: 600; font-size: 0.92rem; }
.hint { font-size: 0.82rem; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--box); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-width: 0;
}
textarea { resize: vertical; min-height: 64px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.invalid input, .invalid select, .invalid textarea { border-color: var(--err); }
.err { color: var(--err); font-size: 0.84rem; }
.err:empty { display: none; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; background: var(--box); cursor: pointer; font-weight: 500; font-size: 0.95rem; }
.choice input { accent-color: var(--navy); width: 17px; height: 17px; margin: 0; }
.choice:has(input:checked) { border-color: var(--navy); background: color-mix(in srgb, var(--navy) 9%, var(--box)); }
.inline { display: flex; gap: 8px; align-items: flex-start; }
.inline > .cc { flex: 0 0 76px; }
.inline > .grow { flex: 1 1 auto; min-width: 0; }

/* The form's own character boxes, echoed under the input */
.boxes { display: grid; grid-template-columns: repeat(var(--n, 25), minmax(0, 1fr)); max-width: calc(var(--n, 25) * 1.2rem); font-family: var(--font-mono); font-size: 0.68rem; line-height: 1; }
.boxes span { height: 1.25rem; border: 1px solid var(--line); margin-right: -1px; display: grid; place-items: center; color: var(--navy); background: var(--box); min-width: 0; overflow: hidden; }
.boxes span.sp { background: transparent; }
.boxes.over span.x { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.boxes-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.boxes-meta.over { color: var(--err); }

.callout { border-left: 3px solid var(--marigold); background: var(--marigold-soft); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 0.92rem; }
.callout.ok { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--card)); }

.media { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.photo-frame { width: 140px; aspect-ratio: 35 / 45; max-width: 100%; border: 1.5px dashed var(--line); border-radius: 6px; background: var(--box); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 0.78rem; text-align: center; padding: 6px; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-frame:has(img) { padding: 0; border-style: solid; }
.sig-pad { width: 100%; max-width: 100%; aspect-ratio: 3 / 1; border: 1.5px dashed var(--line); border-radius: 8px; background: #ffffff; touch-action: none; display: block; }
.sig-preview { width: 100%; aspect-ratio: 3 / 1; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; display: grid; place-items: center; overflow: hidden; }
.sig-preview img { max-width: 92%; max-height: 88%; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs button { font: inherit; font-size: 0.9rem; border: 0; background: var(--box); color: var(--ink); padding: 6px 14px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--navy); color: var(--navy-ink); }

.btn { font: inherit; font-weight: 600; border-radius: 9px; padding: 10px 18px; border: 1.5px solid var(--navy); background: var(--navy); color: var(--navy-ink); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.quiet { border-color: var(--line); background: var(--card); color: var(--ink); font-weight: 500; padding: 7px 12px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.big { padding: 13px 22px; font-size: 1.05rem; }

.navbar { position: fixed; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 5; }
.navbar-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.navbar .where { font-size: 0.85rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.review { display: grid; gap: 10px; }
.review dl { display: grid; grid-template-columns: minmax(110px, 36%) 1fr; gap: 4px 14px; margin: 0; font-size: 0.93rem; }
.review dt { color: var(--muted); }
.review dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.review-block { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.review-block header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.linkish { font: inherit; font-size: 0.85rem; background: none; border: 0; color: var(--navy); cursor: pointer; text-decoration: underline; padding: 0; }
.status { font-size: 0.92rem; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--err); }
.pages { display: grid; gap: 12px; }
.pages canvas { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.next-steps { display: grid; gap: 8px; counter-reset: s; }
.next-steps li { list-style: none; display: grid; grid-template-columns: 26px 1fr; gap: 8px; }
.next-steps li::before { counter-increment: s; content: counter(s); font-family: var(--font-mono); font-size: 0.8rem; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; color: var(--navy); }
.next-steps { padding: 0; margin: 0; }
footer.foot { margin-top: 28px; font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
@media (prefers-reduced-motion: no-preference) { .panel { animation: rise .18s ease-out; } @keyframes rise { from { transform: translateY(4px); opacity: .6 } to { transform: none; opacity: 1 } } }
@media (max-width: 480px) { .panel { padding: 14px; } .review dl { grid-template-columns: 1fr; } .review dt { margin-top: 4px; } }

/* ---- Fill on the form ---- */
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 16px; font-size: 0.9rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.howto div { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.howto .k { font-family: var(--font-mono); font-size: 0.75rem; color: var(--navy); font-weight: 600; flex: 0 0 auto; }

.toolbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6; background: color-mix(in srgb, var(--card) 95%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.zoom { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.zoom button { font: inherit; font-size: 0.9rem; border: 0; background: var(--card); color: var(--ink); padding: 5px 11px; cursor: pointer; min-width: 36px; }
.zoom button + button { border-left: 1px solid var(--line); }
.zoom output { font-family: var(--font-mono); font-size: 0.8rem; padding: 5px 8px; border-left: 1px solid var(--line); min-width: 52px; text-align: center; }
.hintline { flex: 1 1 260px; min-width: 0; font-size: 0.85rem; color: var(--muted); }
.hintline b { color: var(--ink); }
@media (max-width: 560px) {
  .toolbar { gap: 6px 8px; padding: 6px 8px; }
  .toolbar .btn.quiet { padding: 4px 10px; font-size: 0.85rem; }
  .hintline { order: 5; flex-basis: 100%; font-size: 0.8rem; line-height: 1.35; }
}


/* The work surface */
.sheet-scroll { overflow: auto; border-radius: 10px; -webkit-overflow-scrolling: touch; max-width: 100%; }
.sheet { width: calc(var(--zoom, 1) * 100%); display: flex; flex-direction: column; gap: 14px; }
.page { position: relative; width: 100%; aspect-ratio: 595.276 / 841.89; background: #fff; box-shadow: 0 1px 2px rgba(20, 30, 50, .12), 0 6px 18px rgba(20, 30, 50, .08); container-type: inline-size; }
.page > img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; pointer-events: none; }
.page { --u: calc(100cqw / 595.276); }
.ov { position: absolute; margin: 0; }
input.bx, input.tx {
  border: 0; border-radius: 0; background: transparent; color: var(--fill-ink); font-weight: 600; padding: 0; outline: none;
  font-family: var(--font-mono); text-transform: uppercase; height: auto; line-height: 1; caret-color: var(--marigold); min-width: 0;
}
input.bx { font-size: calc(var(--u) * 8.4); letter-spacing: calc(var(--u) * (var(--w) - 5.04)); padding-left: calc(var(--u) * (var(--w) - 5.04) / 2); }
input.tx { font-family: var(--font-body); font-size: calc(var(--u) * 8); padding-left: calc(var(--u) * 3); text-transform: none; }
input.tx.up { text-transform: uppercase; }
input.tx.sm { font-size: calc(var(--u) * 5); }
input.bx:focus, input.tx:focus { background: var(--focus-wash); }
.ov.bad { background: rgba(220, 40, 30, 0.13) !important; box-shadow: 0 0 0 calc(var(--u) * 1) rgba(200, 30, 20, 0.7); }
button.tk { border: 0; padding: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
button.tk:hover { background: var(--focus-wash); }
button.tk[aria-pressed="true"] { background: #fff; }
button.tk svg { width: 78%; height: 78%; opacity: 0; }
button.tk[aria-pressed="true"] svg { opacity: 1; }
.media-spot { border: 0; background: rgba(31, 61, 112, 0.04); cursor: pointer; padding: 0; display: grid; place-items: center; color: #1f3d70; font-family: var(--font-body); font-size: calc(var(--u) * 7.5); font-weight: 600; text-align: center; line-height: 1.25; overflow: hidden; }
.media-spot:hover { background: var(--focus-wash); }
.media-spot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-spot.sig img { object-fit: contain; object-position: center; width: 92%; height: 84%; }
.sig-across { pointer-events: none; display: grid; place-items: center; }
.sig-across img { max-width: 100%; max-height: 100%; }
.office-note { pointer-events: none; font-family: var(--font-body); font-size: calc(var(--u) * 6.5); color: #8a5a10; display: flex; align-items: center; font-style: italic; }

/* Checks and download */
.s-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.issues { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.issues li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; border-left: 3px solid var(--err); background: var(--err-soft); padding: 6px 10px; border-radius: 0 8px 8px 0; font-size: 0.9rem; }
.issues li button { font: inherit; font-size: 0.85rem; background: none; border: 0; color: var(--navy); text-decoration: underline; cursor: pointer; flex: 0 0 auto; }
.okmsg { border-left: 3px solid var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--card)); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: 0.92rem; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 0.95rem; }
.consent input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--navy); flex: 0 0 auto; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Signature sheet */
.modal { position: fixed; inset: 0; background: rgba(10, 16, 28, 0.55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--card); border-radius: 14px; padding: 16px; width: min(640px, 100%); display: flex; flex-direction: column; gap: 12px; max-height: 100%; overflow: auto; }
.sig-pad { width: 100%; aspect-ratio: 3 / 1; border: 1.5px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; display: block; }

.howto .k { min-width: 3.4rem; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 18px; }
.modes button { text-align: left; font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modes button span { font-size: 0.86rem; color: var(--muted); }
.modes button[aria-selected="true"] { border-color: var(--navy); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy) 18%, transparent); }
body.mode-form .wrap { max-width: 980px; padding-block-end: 40px; }
#modeF { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
input.bx, input.tx { width: auto; border-radius: 0; }
input.bx:focus-visible, input.tx:focus-visible { outline: none; }
.s-intro { display: flex; flex-direction: column; gap: 4px; }

/* ---- shared additions for the NKS PAN forms ---- */
.page { --fill-ink: #0f2a6b; --focus-wash: rgba(201, 122, 18, 0.16); color: #0f2a6b; }
.topnav { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.88rem; }
.topnav a { color: var(--navy); text-decoration: none; font-weight: 600; }
.topnav a:hover { text-decoration: underline; }
.q-item { display: flex; flex-direction: column; gap: 6px; }
.q-sub { display: flex; flex-direction: column; gap: 12px; }
.send { display: flex; flex-direction: column; gap: 10px; }
.send .row a.btn { text-decoration: none; }
.wa { background: #1f8a4c; border-color: #1f8a4c; color: #fff; }
.choices.col { flex-direction: column; align-items: flex-start; }
.privacy { font-size: 0.85rem; color: var(--muted); }
textarea.wrapname { text-transform: uppercase; }
input.up { text-transform: uppercase; }
.media-spot { background: rgba(255, 255, 255, 0.86); }

/* Brand logo in the PAN masthead */
.brand { flex-wrap: wrap; gap: 6px 14px; }
.brand-logo { display: block; height: 42px; width: auto; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo { background: #fff; border-radius: 8px; padding: 4px 8px; } }
:root[data-theme="dark"] .brand-logo { background: #fff; border-radius: 8px; padding: 4px 8px; }
