/* Field Surface tokens from the live REOS app (app.revenuengine.io).
   IBM Plex Sans body, Barlow Condensed display. Copper is the action colour.
   Dancing Script is only for a typed signature. */

:root {
  color-scheme: light;
  --color-bone: #F5F0E8;
  --color-bone-deep: #EBE4D8;
  --color-navy: #1E2A3A;
  --color-charcoal: #1A2330;
  --color-ink: #2A3544;
  --color-copper: #C46A34;
  --color-copper-hover: #A85728;
  --color-trust: #4A6B4D;
  --color-amber: #B8862A;
  --color-diag: #2E6A9E;
  --color-muted: #6B7280;
  --color-card: #FFFFFF;
  --color-border: #D9D2C5;
  --color-error: #8B1A1A;

  --bone: var(--color-bone);
  --bone-deep: var(--color-bone-deep);
  --navy: var(--color-navy);
  --charcoal: var(--color-charcoal);
  --ink: var(--color-ink);
  --copper: var(--color-copper);
  --copper-hover: var(--color-copper-hover);
  --trust: var(--color-trust);
  --amber: var(--color-amber);
  --diag: var(--color-diag);
  --muted: var(--color-muted);
  --card: var(--color-card);
  --border: var(--color-border);
  --error: var(--color-error);

  --radius: 0.375rem;
  --radius-card: 0.75rem;
  --shadow: 0 1px 2px rgba(30, 42, 58, 0.06);

  --head: 'Barlow Condensed', 'Arial Narrow', 'Helvetica Neue', sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --script: 'Dancing Script', 'Segoe Script', 'Snell Roundhand', cursive;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
a { color: var(--copper); text-underline-offset: 3px; }
a:hover { color: var(--copper-hover); }
code { font-family: var(--mono); font-size: 0.85em; word-break: break-all; }

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bone);
}

/* ---------- Type ---------- */

.eyebrow {
  margin: 0 0 8px;
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--copper); }

.display {
  margin: 0;
  font-family: var(--head);
  font-weight: 600;
  font-size: clamp(1.85rem, 5vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--navy);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.logo { display: block; width: 190px; height: auto; margin: 0 0 18px; }
.lede { margin: 12px 0 0; font-size: 1rem; color: var(--muted); max-width: 48ch; }
.muted { color: var(--muted); }
.fine { margin: 14px 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; }

/* ---------- Layout ---------- */

.shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-block: max(28px, env(safe-area-inset-top)) max(56px, env(safe-area-inset-bottom));
  padding-inline: 16px;
}

.shell.wide { max-width: 1080px; }
.hero { padding: 6px 0 20px; }
.stack { display: grid; gap: 16px; }
.shell > .card { margin-bottom: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 32px);
}

.card-title {
  margin: 0 0 16px;
  font-family: var(--head);
  font-weight: 600;
  font-size: clamp(1.45rem, 4vw, 1.75rem);
  line-height: 1.1;
  color: var(--navy);
  scroll-margin-top: 16px;
}

.card-title:focus { outline: none; }
.card h2 {
  font-family: var(--head);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--navy);
  margin: 0 0 12px;
}

/* ---------- One screen at a time ----------
   Without the script every screen is shown, stacked. With it, body gets .wizard and only the
   current screen is visible. */

.stepper, .pager { display: none; }
body.wizard .screen:not(.is-current) { display: none; }
body.wizard.not-first .lede { display: none; }
body.wizard.is-done .screen, body.wizard.is-done .stepper, body.wizard.is-done .pager { display: none; }

body.wizard .stepper {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  border-block: 1px solid var(--border);
  scroll-margin-top: 12px;
}

.stepper button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 64px;
  padding: 10px 2px;
  font-family: var(--body);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.stepper .num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  letter-spacing: 0;
  background: var(--card);
}

.stepper li.is-past button { color: var(--ink); }
.stepper li.is-past .num { color: var(--copper); border-color: var(--copper); }
.stepper li.is-current button { color: var(--navy); }
.stepper li.is-current .num { color: #fff; background: var(--navy); border-color: var(--navy); }
.stepper button:focus-visible { outline: 2px solid var(--copper); outline-offset: -2px; }

/* Back and Next stay in reach at the bottom of the screen. */
body.wizard .pager {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding: 18px 0 max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bone) 60%, rgba(245, 240, 232, 0));
}

.pager .btn-primary { flex: 1; width: auto; }
.pager .btn-back {
  flex: none;
  min-width: 108px;
  min-height: 48px;
  padding: 0 18px;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--navy);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.pager .btn-back:hover { background: var(--bone-deep); }
.pager .btn-back:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

/* ---------- Long text (overview and agreement) ---------- */

.prose { font-size: 1rem; line-height: 1.65; color: var(--ink); }
.prose h3 {
  margin: 28px 0 8px;
  font-family: var(--head);
  font-weight: 600;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--navy);
  scroll-margin-top: 16px;
}
.prose h4 {
  margin: 22px 0 6px;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.prose p { margin: 10px 0; }
.prose ul, .prose ol { margin: 10px 0; padding-left: 22px; }
.prose li + li { margin-top: 5px; }
.prose li::marker { color: var(--copper); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 26px 0 0; }
.prose strong { font-weight: 600; color: var(--navy); }
.prose a { font-weight: 500; }
.prose blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  font-style: italic;
  color: var(--ink);
  background: var(--bone);
  border-left: 3px solid var(--copper);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote p { margin: 0; }

.table-scroll { overflow-x: auto; margin: 14px 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.92rem; line-height: 1.45; }
.prose th, .prose td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th {
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.prose td:first-child { min-width: 7.5em; }

@media (max-width: 560px) {
  .prose table { font-size: 0.82rem; }
  .prose th, .prose td { padding: 8px 5px; }
  .prose th { letter-spacing: 0.03em; white-space: normal; }
  .prose td:first-child { min-width: 0; }
}

/* ---------- Form ---------- */

.field { margin: 0 0 20px; padding: 0; border: 0; min-width: 0; }

label, legend {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.optional { margin-left: 6px; font-weight: 500; font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

input:not([type='radio']):not([type='checkbox']),
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--navy);
  background: var(--bone);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  appearance: none;
}

textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(196, 106, 52, 0.4);
}

[aria-invalid='true'] { border-color: var(--error) !important; box-shadow: 0 0 0 3px rgba(139, 26, 26, 0.18); }

.field-hint { margin: 0 0 8px; font-size: 0.85rem; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--muted); }
.field-error, .form-error { margin: 8px 0 0; font-size: 0.9rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--error); }
.form-error { text-align: center; margin-top: 12px; }
.application-intro {
  margin: 0 0 24px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--bone);
  border-left: 3px solid var(--copper);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Short lists of answers as tap targets */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; margin: 0; font-weight: 500; }
.pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.pill span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bone);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.pill input:checked + span {
  color: var(--navy);
  background: rgba(196, 106, 52, 0.1);
  border-color: var(--copper);
  font-weight: 600;
}
.pill input:focus-visible + span { outline: 2px solid var(--copper); outline-offset: 2px; }

/* Ticks */
.consents legend { margin-bottom: 12px; }

.consent {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: start;
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  line-height: 1.5;
  cursor: pointer;
}

.consent input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--copper); cursor: pointer; }
.consent:has(input:focus-visible) { outline: 2px solid var(--copper); outline-offset: 4px; }

/* Signature pad */
.signature { margin-top: 24px; }
.sig-mode { margin-bottom: 12px; }

.pad {
  position: relative;
  height: 190px;
  background: var(--bone);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.pad canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pad.is-typed canvas { cursor: default; }

.pad-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 16px;
  font-family: var(--body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.pad::before {
  content: '';
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 42px;
  border-bottom: 1px solid var(--border);
  pointer-events: none;
}

.pad .pad-clear { position: absolute; right: 8px; bottom: 4px; margin: 0; color: var(--copper); }
.pad .pad-clear:hover { color: var(--copper-hover); }
.pad .pad-clear:focus-visible { outline-color: var(--copper); }
.signature .field-hint { margin: 10px 0 0; }

/* ---------- Buttons ---------- */

.btn-primary {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius);
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  text-transform: none;
  line-height: 1.3;
  color: #fff;
  background: var(--copper);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary:hover { background: var(--copper-hover); color: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-primary:focus-visible, .btn-sm:focus-visible, .btn-tiny:focus-visible, .btn-link:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

.btn-sm {
  display: inline-block;
  padding: 10px 16px;
  font-family: var(--body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #fff;
  background: var(--copper);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}
.btn-sm:hover { background: var(--copper-hover); color: #fff; }

.btn-tiny {
  display: inline-block;
  padding: 9px 12px;
  font-family: var(--body);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--navy);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-tiny:hover { background: var(--bone-deep); color: var(--navy); }

.btn-link {
  padding: 10px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--copper);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-link:hover { color: var(--copper-hover); }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Done ---------- */

.success { color: var(--ink); background: var(--card); border-color: var(--border); }
.success .card-title { color: var(--navy); }
.success p { margin: 10px 0; }
.success .fine { color: var(--muted); }
.success .btn-primary { margin-top: 20px; }

.check-badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  border: 1.5px solid var(--trust);
  border-radius: var(--radius);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--trust);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Signed copy ---------- */

.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 24px; }
.facts dt { font-family: var(--body); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 3px 0 0; overflow-wrap: anywhere; color: var(--navy); }

.sig-block { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 640px) { .sig-block { grid-template-columns: 1fr; } }
.sig-col h2 { margin-bottom: 10px; }
.sig-col p { margin: 8px 0 0; }
.sig-img { display: block; width: min(100%, 320px); height: auto; background: var(--bone); border: 1px solid var(--border); border-radius: var(--radius); }
.countersigned strong { font-size: 1.1rem; color: var(--navy); }

/* ---------- Admin ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}
.stat-n { display: block; font-family: var(--head); font-size: 2.4rem; font-weight: 600; line-height: 1; color: var(--navy); }
.stat-l { display: block; margin-top: 6px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat.hot .stat-n { color: var(--copper); }

.row-between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.row-between h2 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions form { margin: 0; }

.admin table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin th, .admin td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin th { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.admin td { color: var(--ink); }
.admin tbody tr:hover { background: rgba(245, 240, 232, 0.65); }

.pill-status {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bone);
  color: var(--muted);
}
.s-new { color: var(--amber); background: rgba(184, 134, 42, 0.12); border-color: var(--amber); }
.s-accepted { color: var(--trust); background: rgba(74, 107, 77, 0.1); border-color: var(--trust); }
.s-declined { color: var(--muted); }

.warn {
  margin: 0 0 12px;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--navy);
  background: rgba(184, 134, 42, 0.12);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
}
.steps { margin: 0; padding-left: 22px; }
.steps li + li { margin-top: 6px; }
.admin .card { margin-bottom: 16px; }
.admin .facts dd { white-space: normal; }

/* ---------- Print: the signed copy on paper or as a PDF ---------- */

@media print {
  body, .copy { background: #fff !important; color: #000 !important; }
  .bg, .no-print, .hp { display: none !important; }
  .shell { max-width: none; padding: 0; }
  .card, .card.prose { background: none !important; border: 0; box-shadow: none; padding: 0 0 12px; break-inside: auto; }
  .logo { width: 150px; }
  .display { color: #000; font-size: 22pt; }
  .eyebrow, .prose h4 { color: #444; }
  .prose strong, .card h2, .card-title, .prose h3 { color: #000; }
  .prose blockquote { background: none; color: #000; }
  .muted, .lede, .fine, .facts dt { color: #444; }
  .facts dd { color: #000; }
  .prose th, .prose td, .prose hr { border-color: #bbb; }
  .sig-block { break-inside: avoid; }
  a { color: #000; }
}
