/* StampReady Application Builder (builder.html, js/builder.js).
   Same language as the rest of the site: hairline borders carry the structure, flat fills,
   navy ink, one cobalt accent, status colours only for status. */

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.link-btn { padding: 0; border: 0; background: none; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.b-brand { display: inline-flex; align-items: center; gap: 8px; font-size: .9375rem; font-weight: 500; color: var(--ink-2); }
.b-chip { padding: 2px 8px; border: 1px solid var(--accent-line); border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-2); font-size: .75rem; font-weight: 600; }
.b-banner { border-bottom: 1px solid var(--line); background: var(--bg-sub); }
.b-banner p { padding: 11px 0; font-size: .875rem; line-height: 1.5; color: var(--ink-2); }
.b-banner b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- shell --- */
.b-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 48px; align-items: start; padding-top: 36px; padding-bottom: 80px; min-height: 60vh; }
.b-main { min-width: 0; outline: none; }
.b-main h1 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 500; letter-spacing: -.034em; line-height: 1.15; color: var(--slate); }
.b-main h1 span { color: var(--ink); }
.b-h2 { display: flex; align-items: center; gap: 10px; margin: 34px 0 6px; font-size: 1.0625rem; font-weight: 600; letter-spacing: -.02em; color: var(--ink); }

/* The rail: sticky on desktop, one folded line on phones. */
.b-rail { position: sticky; top: 84px; }
.b-rail-fold > summary { display: none; }
.b-rail-body { display: grid; gap: 2px; }
.b-rail-h { margin: 18px 10px 6px; font-size: .8125rem; font-weight: 600; color: var(--ink-3); }
.b-rail-h:first-child { margin-top: 0; }
.b-nav {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  font-size: .9375rem; color: var(--ink-2); text-decoration: none; letter-spacing: -.01em;
}
.b-nav:hover { background: var(--bg-sub); color: var(--ink); text-decoration: none; }
.b-nav.is-on { background: var(--bg-sunk); color: var(--ink); font-weight: 600; }
.b-count { margin-left: auto; padding: 1px 7px; border-radius: var(--r-pill); background: var(--bg-sunk); font-size: .75rem; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.b-count.is-err { background: var(--danger-soft); color: var(--danger); }
.b-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.b-dot {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line-2); font-size: .6875rem; font-weight: 600; color: var(--ink-3); background: var(--bg);
}
.b-dot svg { width: 13px; height: 13px; }
.b-dot.is-done { border-color: var(--ok); background: var(--ok); color: #fff; }
.b-nav.is-on .b-dot:not(.is-done) { border-color: var(--ink); color: var(--ink); }

/* ---------------------------------------------------------------- start --- */
.b-start { max-width: 720px; }
.b-start h1 { font-size: clamp(2rem, 3.6vw, 2.8rem); }
.b-start .lead { margin-top: 16px; font-size: 1.0625rem; line-height: 1.6; color: var(--ink-2); }
.b-flow { list-style: none; margin: 30px 0; padding: 0; counter-reset: f; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.b-flow li { counter-increment: f; padding: 18px 18px 0 0; display: grid; gap: 6px; }
.b-flow li::before { content: '0' counter(f); font: 500 .8125rem var(--mono, monospace); color: var(--accent); }
.b-flow b { font-size: 1rem; font-weight: 600; letter-spacing: -.015em; }
.b-flow span { font-size: .875rem; line-height: 1.5; color: var(--ink-2); }
.b-start-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.b-file { position: relative; overflow: hidden; }
.b-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------------------------------------------------------------- steps --- */
.b-step { max-width: 720px; }
.b-step-head h1 { margin-top: 8px; }
.b-step-head .muted { margin-top: 8px; font-size: 1rem; line-height: 1.55; }
.b-meter { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 12px; }
.b-meter span { height: 4px; border-radius: 4px; background: var(--line); }
.b-meter span.done { background: var(--ok); }
.b-meter span.here { background: var(--ink); }
.b-form { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 18px; margin-top: 28px; }
.b-field { grid-column: 1 / -1; }
.b-field.half { grid-column: span 1; }
.b-form textarea { min-height: 88px; resize: vertical; }
.b-seg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.b-seg label { position: relative; }
.b-seg input { position: absolute; opacity: 0; pointer-events: none; }
.b-seg span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  font-size: .9375rem; color: var(--ink-2); background: var(--bg); cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease);
}
.b-seg span:hover { border-color: var(--line-3); color: var(--ink); }
.b-seg input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.b-seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.b-list { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; min-width: 0; }
.b-list legend { padding: 0; margin-bottom: 10px; font-size: .9375rem; font-weight: 500; color: var(--ink); }
.b-row {
  position: relative; display: grid; grid-template-columns: 30px repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; align-items: end;
  padding: 14px 44px 14px 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg);
}
.b-row-n { align-self: center; font: 500 .8125rem var(--mono, monospace); color: var(--ink-3); }
.b-cell label { font-size: .8125rem; }
.b-row-x {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--ink-3); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.b-row-x:hover { background: var(--bg-sub); color: var(--danger); }
.b-still { margin-top: 22px; padding: 11px 14px; border: 1px solid var(--warn-line); border-radius: var(--r-sm); background: var(--warn-soft); font-size: .875rem; line-height: 1.5; color: var(--warn); }
.b-step-nav { display: flex; justify-content: space-between; gap: 12px; margin: 26px 0 12px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------- overview --- */
.b-over-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.b-over-head .muted { margin-top: 8px; }
.b-progress { margin-top: 26px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--r-lg); }
.b-progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.b-progress-top b { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.02em; }
.b-progress-top span { font-size: 1.5rem; font-weight: 600; letter-spacing: -.04em; font-variant-numeric: tabular-nums; color: var(--accent); }
.b-bar { height: 8px; border-radius: 8px; background: var(--bg-sunk); overflow: hidden; }
.b-bar span { display: block; height: 100%; border-radius: 8px; background: var(--accent); transition: width .4s var(--ease); }
.b-progress .note-line { margin-top: 12px; }
.b-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.b-stat { display: grid; gap: 2px; padding: 16px 18px; color: var(--ink); text-decoration: none; }
.b-stat + .b-stat { border-left: 1px solid var(--line); }
.b-stat:hover { background: var(--bg-sub); text-decoration: none; }
.b-stat span { font-size: .8125rem; font-weight: 600; color: var(--ink-3); }
.b-stat b { font-size: 1.75rem; font-weight: 600; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.b-stat b small { font-size: 1rem; font-weight: 500; color: var(--ink-3); }
.b-stat em { font-style: normal; font-size: .8125rem; color: var(--ink-2); }
.b-stat.is-err b { color: var(--danger); }
.b-cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; }
.b-next { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--line); }
.b-next li { border-bottom: 1px solid var(--line); }
.b-next a { display: flex; align-items: center; gap: 12px; padding: 13px 2px; color: var(--ink); text-decoration: none; font-size: .9375rem; }
.b-next a::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.b-next .k-error a::before { background: var(--danger); }
.b-next .k-missing a::before { background: var(--warn); }
.b-next .k-doc a::before { background: var(--accent); }
.b-next a::after { content: '›'; margin-left: auto; color: var(--ink-3); }
.b-next a:hover { color: var(--accent); }
.b-doclist { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--line); }
.b-doclist a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.b-doclist b { font-weight: 500; font-size: .9375rem; }
.b-state { flex: none; padding: 2px 9px; border-radius: var(--r-pill); font-size: .75rem; font-weight: 600; background: var(--neutral-soft); color: var(--neutral); }
.b-state.ok { background: var(--ok-soft); color: var(--ok); }
.b-state.warn { background: var(--warn-soft); color: var(--warn); }
.b-final { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.b-final li { display: flex; gap: 10px; align-items: flex-start; font-size: .9375rem; line-height: 1.45; color: var(--ink-2); }
.b-final small { color: var(--ink-3); }
.b-tick { flex: none; width: 18px; height: 18px; margin-top: 1px; border: 1.5px solid var(--line-3); border-radius: 5px; }
.b-final li.ok { color: var(--ink); }
.b-final li.ok .b-tick { border-color: var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.5 10.5l3.4 3.3L15.5 6' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.b-final li.manual .b-tick { border-style: dashed; }
.b-danger { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------- checklist --- */
.b-cl > .muted, .b-checks > .muted { margin-top: 10px; max-width: 70ch; line-height: 1.6; }
.b-cl-def { margin-bottom: 12px; font-size: .875rem; color: var(--ink-3); }
.b-doc { margin-bottom: 10px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); transition: border-color .2s var(--ease); }
.b-doc.st-ready { border-color: var(--ok-line); }
.b-doc.st-na { opacity: .65; }
.b-doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.b-doc-head h3 { font-size: 1rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.35; }
.b-lv { flex: none; padding: 2px 9px; border-radius: var(--r-pill); font-size: .75rem; font-weight: 600; border: 1px solid; }
.lv-mandatory { color: var(--ink); border-color: var(--line-3); }
.lv-conditional { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-soft); }
.lv-supplementary { color: var(--ink-3); border-color: var(--line); }
.b-doc-meta { display: grid; gap: 8px; margin: 12px 0 14px; }
.b-doc-meta div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
.b-doc-meta dt { font-size: .8125rem; font-weight: 600; color: var(--ink-3); }
.b-doc-meta dd { margin: 0; font-size: .9063rem; line-height: 1.55; color: var(--ink-2); }
.b-status { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.b-status label { position: relative; }
.b-status input { position: absolute; opacity: 0; pointer-events: none; }
.b-status span { display: block; padding: 7px 13px; font-size: .8125rem; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.b-status label + label span { border-left: 1px solid var(--line-2); }
.b-status input:checked + span { background: var(--ink); color: #fff; }
.b-status input[value="ready"]:checked + span { background: var(--ok); }
.b-status input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ------------------------------------------------------------- documents --- */
.b-tabs { display: flex; gap: 4px; margin: 22px 0 0; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.b-tabs a { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; white-space: nowrap; font-size: .9375rem; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.b-tabs a.is-on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.b-pip { width: 7px; height: 7px; border-radius: 50%; }
.b-pip.warn { background: var(--warn); }
.b-pip.ok { background: var(--ok); }
.b-editor { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.b-editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--bg-sub); font-size: .9375rem; }
.b-stale { margin: 14px 18px 0; }
.b-text {
  display: block; width: 100%; min-height: 360px; padding: 26px 28px; border: 0; outline: 0; resize: none;
  font: 400 .9688rem/1.7 var(--sans); color: var(--ink); background: var(--bg); letter-spacing: -.005em;
}
.b-text:focus { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.b-editor-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.b-doc-issues { margin-top: 8px; }

/* ---------------------------------------------------------------- checks --- */
.b-kinds { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 22px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.b-kind { display: grid; gap: 2px; padding: 16px 18px; text-decoration: none; color: var(--ink); }
.b-kind + .b-kind { border-left: 1px solid var(--line); }
.b-kind:hover { background: var(--bg-sub); text-decoration: none; }
.b-kind b { font-size: 1.75rem; font-weight: 600; letter-spacing: -.04em; }
.b-kind span { font-size: .875rem; color: var(--ink-2); }
.b-kind.k-error b { color: var(--danger); }
.b-kind.k-missing b { color: var(--warn); }
.b-kind.k-review b { color: var(--info); }
.b-find { margin-bottom: 10px; padding: 16px 18px 16px 20px; border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r); }
.b-find.k-error { border-left-color: var(--danger); }
.b-find.k-missing { border-left-color: var(--warn); }
.b-find.k-review { border-left-color: var(--info); }
.b-find h3 { font-size: 1rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.4; }
.b-find p { margin-top: 6px; font-size: .9063rem; line-height: 1.55; color: var(--ink-2); }
.b-find-fix b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.b-find .btn { margin-top: 12px; }

/* --------------------------------------------------------------- printing --- */
.b-print { display: none; }
@media print {
  body.b-printing > *:not(#printArea) { display: none !important; }
  body.b-printing #printArea { display: block; }
  .b-letter { font: 11pt/1.6 var(--sans); color: #000; }
  .b-letter p { margin: 0 0 10pt; }
  .b-letter mark { background: none; border-bottom: 1px dashed #999; color: #000; }
  .b-letter table { width: 100%; border-collapse: collapse; margin: 6pt 0 14pt; }
  .b-letter th, .b-letter td { text-align: left; vertical-align: top; border-bottom: 1px solid #ccc; padding: 6pt 4pt; font-size: 10pt; }
  .b-letter h1 { font-size: 16pt; } .b-letter h2 { font-size: 12pt; margin-top: 14pt; }
}

/* ---------------------------------------------------------------- phones --- */
@media (max-width: 899px) {
  .b-shell { grid-template-columns: 1fr; gap: 18px; padding-top: 0; }
  .b-rail { position: sticky; top: 64px; z-index: 30; margin: 0 -20px; padding: 0 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .b-rail-fold > summary {
    display: flex; align-items: center; gap: 12px; min-height: 52px; list-style: none; cursor: pointer;
    font-size: .9375rem;
  }
  .b-rail-fold > summary::-webkit-details-marker { display: none; }
  .b-rail-fold > summary::after { content: ''; width: 9px; height: 9px; border-right: 1.8px solid var(--ink-2); border-bottom: 1.8px solid var(--ink-2); transform: rotate(45deg) translateY(-3px); flex: none; transition: transform .2s; }
  .b-rail-fold[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
  .b-rail-here { flex: 1; min-width: 0; font-weight: 600; color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .b-rail-pct { flex: none; font-size: .8125rem; color: var(--ink-3); }
  .b-rail-body { max-height: 65vh; overflow-y: auto; padding-bottom: 14px; }
  .b-nav { min-height: 44px; }
  .b-main { padding-top: 10px; }
  .b-flow { grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .b-cols { grid-template-columns: 1fr; gap: 0; }
  .b-stats { grid-template-columns: 1fr 1fr; }
  .b-stat:nth-child(3) { border-left: 0; }
  .b-stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 600px) {
  .b-form { grid-template-columns: 1fr; }
  .b-field.half { grid-column: 1 / -1; }
  .b-row { grid-template-columns: 1fr 1fr; padding: 40px 14px 14px; }
  .b-row-n { position: absolute; top: 14px; left: 14px; }
  .b-cell-text, .b-cell-select { grid-column: 1 / -1; }
  .b-seg span { min-height: 46px; }
  .b-step-nav .btn { flex: 1; justify-content: center; }
  .b-doc { padding: 16px; }
  .b-doc-meta div { grid-template-columns: 1fr; gap: 2px; }
  .b-status { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .b-status label + label span { border-left: 0; }
  .b-status label:nth-child(even) span { border-left: 1px solid var(--line-2); }
  .b-status label:nth-child(n+3) span { border-top: 1px solid var(--line-2); }
  .b-status span { text-align: center; padding: 10px 8px; }
  .b-text { padding: 18px 16px; font-size: 1rem; }
  .b-kinds { grid-template-columns: 1fr; }
  .b-kind + .b-kind { border-left: 0; border-top: 1px solid var(--line); }
  .b-kind { grid-template-columns: 56px 1fr; align-items: center; }
  .b-flow { grid-template-columns: 1fr; }
  .b-over-head .btn { width: 100%; justify-content: center; }
  .b-editor-tools .btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 600px) { .b-brand-t { display: none; } }
.b-step-head h1 { color: var(--ink); }
