/* ==========================================================================
   Provider Portal Registration - stylesheet
   Organised as:
     1. Design tokens
     2. Reset & base
     3. Layout
     4. Header & footer
     5. Cards & typography
     6. Forms
     7. Radio / checkbox cards
     8. User parser preview
     9. Buttons
    10. Sticky submit panel
    11. Success page
    12. Responsive
    13. Partner form page (partner-form.html)
    14. The printed document
   ========================================================================== */

/* -- 1. Design tokens ---------------------------------------------------- */
/* Palette sampled from the CHS / HVPN / QualCare logo cluster:
   CHS navy + red, HVPN blue, QualCare green. Adjust here only. */
:root {
  --blue-900: #16274f;  /* CHS navy            */
  --blue-700: #1c4b9c;  /* HVPN blue           */
  --blue-600: #21579f;
  --blue-500: #3f7ac4;
  --blue-100: #dde6f4;
  --blue-050: #f2f6fc;

  --brand-red:   #e03a3e;  /* CHS swoosh / underline accent */
  --brand-green: #00a650;  /* QualCare                      */

  --ink:        #16202c;
  --ink-muted:  #56657a;
  --line:       #d9e1ec;
  --line-soft:  #eaeff6;
  --surface:    #ffffff;
  --canvas:     #f4f7fb;

  --amber-bg:   #fff8e6;
  --amber-line: #f0d089;
  --amber-ink:  #7a5309;

  --red-600:    #b4271f;
  --red-bg:     #fdeceb;

  --green-600:  #1a7f4b;

  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 2px rgba(16, 32, 51, .06), 0 4px 14px rgba(16, 32, 51, .05);
  --shadow-up:  0 -6px 20px rgba(16, 32, 51, .10);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

  --container: 1080px;
}

/* -- 2. Reset & base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--blue-700); }
code { font-family: var(--mono); font-size: .875em; background: var(--blue-050); padding: 0 .25em; border-radius: 3px; }

.muted { color: var(--ink-muted); }
.muted-label { color: var(--ink-muted); font-weight: 400; }
.req { color: var(--red-600); }

/* -- 3. Layout ----------------------------------------------------------- */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.page {
  padding-top: 1.75rem;
  /* Room for the sticky submit panel. */
  padding-bottom: 15rem;
}

/* -- 4. Header & footer -------------------------------------------------- */
/* White header so the multi-colour logo cluster sits on its native background,
   with a red rule underneath picked up from the CHS mark. */
.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--brand-red);
  box-shadow: 0 1px 3px rgba(16, 32, 51, .07);
}

/* Everything in the header is a single centred column: logo, then the two
   lines of text, then the version. */
.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .55rem;
  padding-top: 1.35rem;
  padding-bottom: 1.35rem;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  min-width: 0;
}

/* The logo cluster is two stacked rows (CHS above HVPN | QualCare) at roughly
   2.2:1, carrying small type in both. Size it by WIDTH - constraining height
   the way you would a single-row wordmark shrinks it until the sub-text is
   unreadable. */
.brand-mark {
  flex: 0 0 auto;
  display: flex; align-items: center;
}
.brand-mark img {
  width: 220px;
  height: auto;
  max-height: 108px;
  object-fit: contain;
}

/* Partner page: a text mark stands in for a logo, so it has to look chosen
   rather than like artwork that failed to load. The rule down one side gives it
   the visual weight a mark needs without borrowing anyone's branding. */
.brand-wordmark {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--blue-900);
  background: var(--blue-050);
  border: 1px solid var(--blue-100);
  border-left: 4px solid var(--blue-700);
  border-radius: var(--radius-sm);
  padding: .5rem .85rem;
  white-space: nowrap;
}

/* Text wordmark fallback, used until the logo file loads. */
.brand-fallback {
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: .02em;
  color: var(--blue-900);
}
.brand-fallback span { color: var(--brand-red); }

.brand-text { min-width: 0; }

.brand-org {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.brand-title { font-size: 1.25rem; margin: 0; font-weight: 700; color: var(--blue-900); }

.header-version {
  margin: 0;
  font-size: .8rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.5rem 0;
  font-size: .85rem;
  color: var(--ink-muted);
}
.site-footer p { margin: 0 0 .25rem; }

/* -- 5. Cards & typography ----------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.15rem;
}

.welcome h2 { font-size: 1.4rem; }

.section-help {
  color: var(--ink-muted);
  font-size: .93rem;
  margin-top: -.15rem;
}

.fine-print {
  font-size: .85rem;
  color: var(--ink-muted);
  margin: 0 .25rem 1.25rem;
}

/* Partner portal notice */
.notice {
  display: flex;
  gap: 1rem;
  background: var(--amber-bg);
  border-color: var(--amber-line);
}
/* `.notice` sets display:flex, which would otherwise defeat the `hidden`
   attribute (equal specificity, later rule wins). Restore hidden for a notice
   that is toggled, like the DH stop notice. */
.notice[hidden] { display: none; }
.notice-icon {
  flex: 0 0 30px; height: 30px;
  border-radius: 50%;
  background: var(--amber-line);
  color: var(--amber-ink);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.notice-body h2 { font-size: 1.08rem; }
.notice-body h3 { font-size: 1.02rem; margin: 0 0 .4rem; }
.notice-body p { color: var(--amber-ink); }

/* A stop notice reads as "you cannot proceed here", so it is red rather than
   the amber advisory tone. It sits inside the portal-check card and appears
   only when the DH answer is Yes. */
.notice-stop {
  margin-top: 1rem;
  /* Its own padding: unlike the page-level notices, this one is not wrapped in
     a .card, so nothing else provides inner spacing. */
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--red-bg);
  border: 1px solid #e9b6b2;
}
.notice-stop .notice-icon { background: #e9b6b2; color: var(--red-600); }
.notice-stop .notice-body h3,
.notice-stop .notice-body p { color: var(--red-600); }
.notice-stop a { color: var(--red-600); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 0; }

.draft-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.draft-card h2 { font-size: 1rem; }
.draft-card p { font-size: .88rem; }

/* -- 6. Forms ------------------------------------------------------------ */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.15rem;
}
.field { margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.field-wide { grid-column: 1 / -1; }

/* On its own row, but the input itself stays the width of a normal column, so
   a phone number does not get a box three times longer than it needs while the
   fields above and below it are half that. The 1.15rem is the grid's gap. */
.field-wide.field-narrow-input input,
.field-wide.field-narrow-input textarea {
  max-width: calc((100% - 1.15rem) / 2);
}

label { font-weight: 600; font-size: .92rem; }

input[type="text"], input[type="email"], input[type="tel"], textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 4.5rem; }

/* Text fields keep the soft glow on focus. Radios and checkboxes are excluded
   here — the square glow around a round radio is what looked wrong. */
input:not([type="radio"]):not([type="checkbox"]):focus,
textarea:focus, button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(34, 128, 212, .22);
}
button:focus-visible, a:focus-visible { box-shadow: 0 0 0 3px rgba(34, 128, 212, .35); }

/* Radios and checkboxes: no ring on a mouse click (`:focus-visible` only fires
   for keyboard navigation), and when it does show it follows the control's
   shape — a circle for radios — instead of a square. */
input[type="radio"] { border-radius: 50%; }
input[type="radio"]:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 128, 212, .40);
}

.field-help { font-size: .8rem; color: var(--ink-muted); }

/* Privacy caution under free-text fields that could attract patient details. */
.caution {
  font-size: .82rem;
  line-height: 1.45;
  color: var(--amber-ink);
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
}

/* Ability checkboxes stack like the radio groups they replaced. */
.check-group { display: grid; gap: .6rem; }

/* A conditional field that belongs to the checkbox above it, indented so the
   relationship is visible rather than inferred. */
.conditional.indented {
  margin: .5rem 0 .9rem 1.6rem;
  padding-left: .9rem;
  border-left: 2px solid var(--line);
}

/* Inside a grid the gap already spaces things, so the conditional field must
   not add margins of its own - otherwise the checkboxes sit flush together
   while it is hidden and too far apart while it is showing. */
.check-group > .conditional.indented { margin: 0 0 0 1.6rem; }

/* Networks are short codes, so they read better in columns than as one long
   list. Deliberately NOT a copy of the paper form's grid: the cards are the
   same component as every other choice on the page, equal in height whatever
   the label length, in even columns. */
/* Wrapped flex items with a fixed basis: four even columns, rows that line up.
   The `gap` does the spacing, so the stacked-checkbox margin rule below must be
   switched off in here or every card after the first is nudged down inside its
   own row. */
.network-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}
.network-grid .check-card + .check-card { margin-top: 0; }

/* A network is a choice like any other: same padding, font, weight and colour
   as every other .check-card on the page. Only two things differ, both because
   these labels are a single short code rather than a title plus help text. */
/* Four to a row: each card is a quarter of the width, less its share of the
   three gaps between them. */
.network-card {
  align-items: center;
  flex: 0 0 calc((100% - 1.8rem) / 4);
  height: 3.15rem;
}
/* .check-card nudges its input down to line up with a two-line label; these
   labels are one line, so that nudge would knock it off centre. */
.network-card input { margin-top: 0; }

.network-name {
  font-weight: 600;
  white-space: nowrap;        /* codes should never break mid-name */
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1100px) { .network-card { flex-basis: calc((100% - 1.2rem) / 3); } }
@media (max-width: 860px)  { .network-card { flex-basis: calc((100% - .6rem) / 2); } }
@media (max-width: 520px)  { .network-card { flex-basis: 100%; } }

/* An in-place message about the section the user is looking at, so they do not
   have to read the checklist at the foot of the page to learn what is wrong. */
.inline-alert {
  margin: .75rem 0 0;
  font-size: .9rem;
  color: var(--amber-ink);
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
}

/* The options that would resolve it. Amber rather than red: nothing is broken,
   there is simply a choice still to make. */
.check-card.needs-choice {
  border-color: var(--amber-line);
  background: var(--amber-bg);
  box-shadow: inset 0 0 0 1px var(--amber-line);
}
.check-card.needs-choice:hover {
  border-color: var(--blue-500);
}

/* Echo of the official role name a set of ticks adds up to. Sized to be read,
   not skimmed past: it is the wording that actually reaches the helpdesk. */
.role-echo:empty { display: none; }
.role-echo {
  margin: .75rem 0 0;
  font-size: .95rem;
  color: var(--blue-900);
  background: var(--blue-050);
  border-left: 3px solid var(--blue-600);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
}

/* Paste-a-list hint above the partner form's user table, and the status line
   that reports what a paste was understood to mean. */
.paste-hint { margin: 0 0 .75rem; }

.paste-status:empty { display: none; }
.paste-status {
  margin: .6rem 0 0;
  font-size: .85rem;
  color: var(--blue-900);
  background: var(--blue-050);
  border: 1px solid var(--blue-100);
  border-left: 3px solid var(--blue-600);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
}

/* Honeypot: off-screen rather than display:none, which some bots skip.
   Kept out of the tab order and the accessibility tree in the markup. */
.hp-field {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Invalid state, applied after a submit attempt and by live field checks. */
.field.is-invalid input,
.field.is-invalid textarea { border-color: var(--red-600); background: var(--red-bg); }

/* Per-field feedback on what was typed. Sits under the input, unlike hints,
   because it is a response to the entry rather than guidance before it. */
.field-feedback:empty { display: none; }
.field-feedback {
  font-size: .82rem;
  line-height: 1.4;
  color: var(--red-600);
  font-weight: 600;
}
.field-feedback.is-ok { color: var(--green-600); }

.conditional { margin-top: 1.1rem; }

/* -- 7. Radio / checkbox cards ------------------------------------------- */
.radio-group { display: grid; gap: .6rem; }

.radio-card, .check-card {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .8rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #fff;
  transition: border-color .12s, background .12s;
}
.radio-card:hover, .check-card:hover { border-color: var(--blue-500); background: var(--blue-050); }

.radio-card input, .check-card input { margin-top: .28rem; flex: 0 0 auto; accent-color: var(--blue-600); }

.radio-card:has(input:checked),
.check-card:has(input:checked) {
  border-color: var(--blue-600);
  background: var(--blue-050);
  box-shadow: inset 0 0 0 1px var(--blue-600);
}

.radio-body, .check-body { display: flex; flex-direction: column; gap: .15rem; }
.radio-title { font-weight: 600; }
.radio-help { font-size: .85rem; color: var(--ink-muted); }

.pill {
  display: inline-block;
  margin-left: .4rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--green-600);
  background: #e7f5ed;
  border-radius: 999px;
  padding: .1rem .5rem;
  vertical-align: middle;
}

/* -- 8. User parser preview ---------------------------------------------- */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
  align-items: start;
}

.preview {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--blue-050);
  padding: .85rem .95rem;
  min-height: 100%;
}
.preview-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .5rem; margin-bottom: .5rem;
}
.preview-head h3 { margin: 0; font-size: .92rem; }
.preview-count { font-size: .8rem; color: var(--ink-muted); }

.preview-list { margin: 0; padding-left: 1.4rem; font-size: .9rem; }
.preview-list li { margin-bottom: .3rem; }
.preview-list .pv-name { font-weight: 600; }
.preview-list .pv-email { color: var(--ink-muted); font-family: var(--mono); font-size: .84em; }
.preview-list .pv-flag { color: var(--red-600); font-size: .82em; }
.preview-empty { color: var(--ink-muted); font-size: .9rem; font-style: italic; margin: 0; }

.preview-warnings { list-style: none; margin: .75rem 0 0; padding: 0; }
.preview-warnings li {
  font-size: .84rem;
  padding: .4rem .55rem;
  border-radius: var(--radius-sm);
  margin-bottom: .35rem;
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: var(--amber-ink);
}
.preview-warnings li.severe {
  background: var(--red-bg);
  border-color: #e9b6b2;
  color: var(--red-600);
}

/* -- 9. Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-700); }
.btn-secondary { background: #fff; color: var(--blue-700); border-color: var(--blue-600); }
.btn-secondary:hover { background: var(--blue-050); }
.btn-quiet { background: transparent; color: var(--blue-700); border-color: var(--line); }
.btn-quiet:hover { background: var(--blue-050); }
.btn-danger { color: var(--red-600); }
.btn-danger:hover { background: var(--red-bg); }
.btn-lg { padding: .8rem 1.6rem; font-size: 1.02rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* -- 10. Sticky submit panel --------------------------------------------- */
.submit-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-up);
  z-index: 20;
}
.submit-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-top: .85rem;
  padding-bottom: .85rem;
}
.submit-status { min-width: 0; }
.submit-headline { margin: 0 0 .35rem; font-size: .9rem; font-weight: 600; }
.submit-headline.ready { color: var(--green-600); }

.checklist {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: .35rem .5rem;
  max-height: 5.5rem;
  overflow-y: auto;
}
.checklist li {
  font-size: .82rem;
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: var(--amber-ink);
  border-radius: 999px;
  padding: .15rem .6rem;
}

/* A chip that knows where its subject lives becomes a button. The padding
   moves onto the button so the whole chip is the click target, not just the
   text inside it. */
.checklist li:has(.chip-link) { padding: 0; }

.chip-link {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 999px;
  padding: .15rem .6rem;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.chip-link:hover { background: rgba(0, 0, 0, .06); text-decoration-style: solid; }

/* Flash whatever a chip sent the user to, so the eye lands in the right place
   rather than somewhere in the middle of a scrolled section. */
@keyframes flash-target {
  0%   { box-shadow: 0 0 0 3px rgba(34, 128, 212, .55); }
  100% { box-shadow: 0 0 0 3px rgba(34, 128, 212, 0); }
}
.flash-target {
  border-radius: var(--radius-sm);
  animation: flash-target 1.8s ease-out;
}

/* Someone who prefers less motion still needs to see where they landed, so
   the highlight stays - it just does not animate or smooth-scroll. */
@media (prefers-reduced-motion: reduce) {
  .flash-target {
    animation: none;
    box-shadow: 0 0 0 3px rgba(34, 128, 212, .45);
  }
  html { scroll-behavior: auto; }
}

.submit-error {
  margin: .5rem 0 0;
  font-size: .85rem;
  color: var(--red-600);
  background: var(--red-bg);
  border: 1px solid #e9b6b2;
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
}

/* -- 11. Success page ---------------------------------------------------- */
.success-card { max-width: 720px; margin: 2rem auto; padding: 2rem; }
.success-badge {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: #e7f5ed;
  color: var(--green-600);
  font-size: 1.7rem;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.success-card h2 { font-size: 1.5rem; }
.success-card h3 { margin-top: 1.5rem; }
.steps { padding-left: 1.25rem; color: var(--ink-muted); }
.steps li { margin-bottom: .4rem; }

/* Confirmation pages: separate the action buttons from the "Questions?" line
   beneath them, and make the buttons a little more compact than in-form ones. */
.success-card .actions { margin-top: 1.75rem; margin-bottom: 1.5rem; }
.success-card .actions .btn { padding: .45rem .85rem; }

.reference-block {
  display: flex; flex-direction: column; gap: .1rem;
  background: var(--blue-050);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
}
.reference-label {
  font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-muted);
}
.reference-number {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--blue-900);
  word-break: break-all;
}

/* -- 12. Responsive ------------------------------------------------------ */
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .submit-inner { flex-direction: column; align-items: stretch; }
  .submit-inner .btn-lg { width: 100%; }
  .checklist { max-height: 4.5rem; }
  .page { padding-bottom: 18rem; }

  /* Stack the logo above the title rather than shrinking both. */
  .brand-mark img { width: 180px; }
}

/* -- 13. Partner form page ----------------------------------------------- */
/* partner-form.html reuses the cards, fields and sticky panel above. What
   follows is only what that page adds: the user table, the fixed network
   callout, and the preview dialog. */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.subhead {
  font-size: .82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 1.25rem 0 .5rem;
}
.card > .subhead:first-of-type { margin-top: .25rem; }

.check-card + .check-card { margin-top: .6rem; }

/* A choice the form makes for the user, shown rather than offered. Styled as a
   statement, not a control, so nobody hunts for the checkbox. */
.fixed-value {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  background: var(--blue-050);
  border: 1px solid var(--blue-100);
  border-left: 3px solid var(--blue-600);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  margin: 0;
}
.fixed-code {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--blue-900);
}
.fixed-note { font-size: .82rem; color: var(--ink-muted); }

/* User table. Scrolls sideways on narrow screens rather than crushing the
   email column into unreadability. */
.user-table-wrap { overflow-x: auto; margin: 1rem 0 .25rem; }

.user-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
}
.user-table th {
  text-align: left;
  font-size: .8rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  padding: 0 .4rem .4rem;
  border-bottom: 1px solid var(--line);
}
.user-table td { padding: .25rem .4rem; vertical-align: middle; }

.user-table .col-num { width: 2rem; }
.user-table .col-remove { width: 2.25rem; }

.row-num { font-size: .85rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.cell-input {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.cell-input:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(34, 128, 212, .22);
}

.row-remove {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  width: 1.9rem; height: 1.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}
.row-remove:hover { background: var(--red-bg); color: var(--red-600); }

.row-count { font-size: .85rem; color: var(--ink-muted); align-self: center; }

.submit-actions { display: flex; gap: .6rem; align-items: center; flex: 0 0 auto; }

/* Advisory items in the sticky checklist: worth reading, never blocking. */
.checklist li.warn {
  background: var(--red-bg);
  border-color: #e9b6b2;
  color: var(--red-600);
}

/* Preview dialog */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 32, 51, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.preview-overlay[hidden] { display: none; }

.preview-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(16, 32, 51, .35);
  width: min(860px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.preview-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.preview-dialog-head h2 { margin: 0; font-size: 1.05rem; }

/* The dialog shows a clone of #print-doc, which is hidden on screen by
   default - re-show it inside the dialog only. */
.preview-dialog-body {
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--canvas);
}
.preview-dialog-body .print-doc {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow);
}

/* -- 14. The printed document -------------------------------------------- */
/* #print-doc is built by partner-form.js from the answers and is the only
   thing that reaches paper. Everything else is marked .no-print. Sizes are in
   pt because this layout is measured against a sheet of paper, not a screen. */

.print-doc { display: none; color: #000; }

.print-doc .p-title {
  font-size: 13pt;
  text-align: center;
  margin: 0 0 .35rem;
  letter-spacing: .01em;
}
.print-doc .p-forward {
  text-align: center;
  font-size: 9.5pt;
  font-weight: 700;
  margin: 0 0 .2rem;
  word-break: break-word;
}
.print-doc .p-warn {
  text-align: center;
  font-size: 8.5pt;
  font-style: italic;
  margin: 0 0 1rem;
}

.print-doc .p-section {
  font-size: 10pt;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #e8e8e8;
  border: 1px solid #999;
  padding: .18rem .4rem;
  margin: .9rem 0 .5rem;
}
.print-doc .p-sub {
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: .6rem 0 .3rem;
}
.print-doc .p-note { font-size: 8.5pt; font-style: italic; margin: 0 0 .4rem; }

.print-doc .p-row {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  font-size: 10pt;
  margin-bottom: .3rem;
}
.print-doc .p-label { flex: 0 0 12rem; font-weight: 700; }
.print-doc .p-value {
  flex: 1 1 auto;
  border-bottom: 1px solid #666;
  min-height: 1.25em;
  padding-left: .2rem;
}

.print-doc .p-opts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .25rem 1rem;
  margin-bottom: .35rem;
}
.print-doc .p-opt {
  display: flex;
  gap: .4rem;
  align-items: flex-start;
  font-size: 9.5pt;
}
/* Unchosen options stay on the page - the recipient is reading the same list
   of choices they know from the paper form - but greyed, so the chosen one is
   unmistakable at a glance. */
.print-doc .p-opt { color: #666; }
.print-doc .p-opt.is-on { color: #000; font-weight: 700; }

.print-doc .p-box {
  flex: 0 0 auto;
  width: 12px; height: 12px;
  border: 1px solid #767676;      /* empty boxes recede */
  border-radius: 2px;
  margin-top: .16em;
  padding: 1px;
  box-sizing: border-box;
}

/* A ticked box is darker and heavier, so the answers are findable by shape
   alone when someone scans the page rather than reads it. */
.print-doc .p-opt.is-on .p-box {
  border-color: #000;
  border-width: 1.5px;
}

.print-doc .p-tick {
  display: block;
  width: 100%; height: 100%;
  overflow: visible;
}
.print-doc .p-tick path {
  fill: none;
  stroke: #000;
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.print-doc .p-users {
  width: 100%;
  border-collapse: collapse;
  font-size: 9pt;
  margin-top: .3rem;
}
.print-doc .p-users th,
.print-doc .p-users td {
  border: 1px solid #666;
  padding: .22rem .35rem;
  text-align: left;
  word-break: break-word;
}
.print-doc .p-users th { background: #e8e8e8; font-size: 8.5pt; text-transform: uppercase; }
.print-doc .p-users-num { width: 1.5rem; text-align: center; color: #555; }

.print-doc .p-foot {
  margin-top: 1rem;
  font-size: 8.5pt;
  font-style: italic;
  color: #333;
}

@media print {
  /* The browser prints the document we built, not a picture of the web page. */
  .no-print { display: none !important; }

  body { background: #fff; }
  .print-doc { display: block; }

  @page { size: letter portrait; margin: 0.5in; }

  /* Browsers drop background colours when printing unless told otherwise. The
     tick is a stroke and prints regardless, but this keeps the table's header
     shading and anything else deliberate from silently vanishing. */
  .print-doc {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Nothing may be split mid-thought across a page break. */
  .print-doc .p-section,
  .print-doc .p-sub { break-after: avoid; page-break-after: avoid; }
  .print-doc .p-opts,
  .print-doc .p-row { break-inside: avoid; page-break-inside: avoid; }
  .print-doc .p-users tr { break-inside: avoid; page-break-inside: avoid; }
  .print-doc .p-users thead { display: table-header-group; }
}
