/* Optional client-friendly layouts on top of the sheet renderer: /?…&ui=paper|cards|steps|accordion|mobile.
   Content, wording, order and required rules are untouched; only presentation and navigation change.
   Everything is scoped to .sheet:not(.pdfmode) so the PDF that goes to Drive keeps the sheet layout. */

:root { --ui-bg: #f4f6f9; --ui-card: #fff; --ui-ink: #1f2937; --ui-accent: #1f4e79; --ui-accent-soft: #e8f0f8;
  --ui-line: #d6dde6; --ui-ok: #15803d; --ui-ok-soft: #e7f6ec; --ui-warn: #b45309; --ui-muted: #64748b; }

/* ---------- shared by every layout: readable text, real answer boxes, bigger tap targets */
body.ui { font-size: 15.5px; }
.ui .sheet:not(.pdfmode) .f:not(table.grid .f), .ui .sheet:not(.pdfmode) select.f {
  border: 1px solid var(--ui-line); border-radius: 6px; background: #fff; min-height: 38px; padding: 7px 10px; }
.ui .sheet:not(.pdfmode) .f:focus, .ui .sheet:not(.pdfmode) .line:focus { outline: 2px solid var(--ui-accent); outline-offset: 0; background: #fff; }
.ui .sheet:not(.pdfmode) .line { border: 1px solid var(--ui-line); border-radius: 6px; min-height: 36px; padding: 6px 9px; background: #fff; }
.ui .sheet:not(.pdfmode) .opt { padding: 4px 2px; gap: 7px; }
.ui .sheet:not(.pdfmode) .opt input { width: 18px; height: 18px; }
.ui .sheet:not(.pdfmode) .sigpad { border: 1px dashed var(--ui-line); border-radius: 6px; background: #fff; }

/* progress bar (all layouts) */
#ui-progress { position: sticky; top: 44px; z-index: 4; height: 6px; background: #dbe3ec; }
#ui-progress > i { display: block; height: 100%; width: 0; background: var(--ui-ok); transition: width .3s; }
#ui-progress-label { font-size: 12px; color: #cbd5e1; white-space: nowrap; }

/* section status pills */
.ui-pill { display: inline-block; font-size: 11.5px; font-weight: bold; border-radius: 999px; padding: 2px 9px; margin-left: 8px; vertical-align: 2px; white-space: nowrap; }
.ui-pill.s-done { background: var(--ui-ok-soft); color: var(--ui-ok); }
.ui-pill.s-part { background: #fff4e0; color: var(--ui-warn); }
.ui-pill.s-todo { background: #eef2f6; color: var(--ui-muted); }
.ui-pill.s-opt { background: #eef2f6; color: var(--ui-muted); font-weight: normal; }

.ui-off { display: none !important; }

/* ---------- 1. paper: the sheet, easier to read */
body.ui-paper .sheet:not(.pdfmode) { font-size: 15.5px; }
body.ui-paper .sheet:not(.pdfmode) .sec-title { font-size: 16px; color: var(--ui-accent); }
#ui-jump { font: inherit; font-size: 13px; max-width: 260px; padding: 4px 6px; border-radius: 4px; border: 1px solid #6b7280; background: #fff; color: #1f2937; }

/* ---------- 2–5. card look */
body.ui-cards, body.ui-steps, body.ui-accordion, body.ui-mobile { background: var(--ui-bg); }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) {
  background: transparent; box-shadow: none; padding: 18px 0 60px; width: 100%; max-width: 820px; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) .letterhead {
  background: var(--ui-card); border-radius: 12px; padding: 20px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) section.sec {
  background: var(--ui-card); border-radius: 12px; padding: 18px 22px; margin: 0 0 14px; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) section.sec.ui-cont { margin-top: -14px; border-top-left-radius: 0; border-top-right-radius: 0; padding-top: 4px; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) .sec-title {
  font-size: 17px; color: var(--ui-accent); border-bottom: 0; padding-bottom: 0; margin-bottom: 12px; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) .banner { font-size: 18px; color: var(--ui-accent); margin: 4px 0 10px; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) table.t td,
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) table.t th { border-color: #e3e8ee; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) table.t th { background: #f7f9fb; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .sheet:not(.pdfmode) table.kv td.lab { background: #fafbfc; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .actions { max-width: 820px; margin: 0 auto; }
:is(.ui-cards, .ui-steps, .ui-accordion, .ui-mobile) .pagefoot { display: none; }

/* ---------- 2. cards + side menu */
#ui-nav { position: fixed; top: 64px; left: 16px; width: 250px; max-height: calc(100vh - 84px); overflow: auto;
  background: var(--ui-card); border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 10px; z-index: 3; font-size: 13px; }
#ui-nav .ui-nav-h { font-weight: bold; color: var(--ui-muted); text-transform: uppercase; font-size: 11px; letter-spacing: .4px; padding: 4px 8px 8px; }
#ui-nav a { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 6px; color: var(--ui-ink); text-decoration: none; line-height: 1.3; }
#ui-nav a:hover { background: var(--ui-accent-soft); }
#ui-nav a.cur { background: var(--ui-accent-soft); font-weight: bold; }
#ui-nav a .ic { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #cbd5e1; font-size: 11px; line-height: 14px; text-align: center; color: #fff; }
#ui-nav a .ic.s-done { background: var(--ui-ok); border-color: var(--ui-ok); }
#ui-nav a .ic.s-part { border-color: var(--ui-warn); }
body.ui-cards .sheet:not(.pdfmode) { margin-left: max(290px, calc((100vw - 820px) / 2)); }
@media (max-width: 1150px) { #ui-nav { display: none; } body.ui-cards .sheet:not(.pdfmode) { margin: 0 auto; } }

/* ---------- 3. step by step */
#ui-stepper { max-width: 820px; margin: 0 auto 12px; background: var(--ui-card); border-radius: 12px; padding: 14px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
#ui-stepper .ui-step-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#ui-stepper .ui-step-n { font-size: 12.5px; color: var(--ui-muted); font-weight: bold; text-transform: uppercase; letter-spacing: .4px; }
#ui-stepper .ui-step-t { font-size: 15px; font-weight: bold; color: var(--ui-accent); }
#ui-stepper .ui-dots { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
#ui-stepper .ui-dots i { flex: 1 1 14px; min-width: 10px; height: 6px; border-radius: 3px; background: #dbe3ec; cursor: pointer; }
#ui-stepper .ui-dots i.s-done { background: var(--ui-ok); }
#ui-stepper .ui-dots i.s-part { background: #f3c27a; }
#ui-stepper .ui-dots i.cur { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.ui-stepnav { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.ui-btn { font: inherit; font-weight: bold; border: 0; border-radius: 8px; padding: 12px 22px; cursor: pointer; background: var(--ui-accent); color: #fff; }
.ui-btn.ghost { background: #fff; color: var(--ui-accent); border: 1px solid var(--ui-line); }
.ui-btn:disabled { opacity: .4; cursor: default; }

/* ---------- 4. accordion */
body.ui-accordion .sheet:not(.pdfmode) section.sec .sec-title,
body.ui-accordion .sheet:not(.pdfmode) section.sec .banner { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 0; }
body.ui-accordion .sheet:not(.pdfmode) section.sec.ui-open .sec-title,
body.ui-accordion .sheet:not(.pdfmode) section.sec.ui-open .banner { margin-bottom: 12px; }
body.ui-accordion .sheet:not(.pdfmode) section.sec.ui-closed > :not(.sec-title):not(.banner) { display: none !important; }
body.ui-accordion .sheet:not(.pdfmode) section.sec.ui-closed.ui-cont { display: none; }
.ui-chev { flex: none; font-size: 14px; color: var(--ui-muted); transition: transform .2s; }
section.ui-open .ui-chev { transform: rotate(90deg); }
.ui-continue { display: block; margin: 16px 0 2px auto; }

/* ---------- 5. phone-first: narrow column, stacked label/answer, tables as stacked cards, bottom bar */
body.ui-mobile .sheet:not(.pdfmode) { max-width: 560px; }
body.ui-mobile .sheet:not(.pdfmode) table.kv, body.ui-mobile .sheet:not(.pdfmode) table.kv tbody,
body.ui-mobile .sheet:not(.pdfmode) table.kv tr, body.ui-mobile .sheet:not(.pdfmode) table.kv td { display: block; width: 100%; }
body.ui-mobile .sheet:not(.pdfmode) table.kv { border: 0; }
body.ui-mobile .sheet:not(.pdfmode) table.kv td { border: 0; padding: 0 0 4px; background: none !important; }
body.ui-mobile .sheet:not(.pdfmode) table.kv tr { padding: 10px 0; border-bottom: 1px solid #eef1f5; }
body.ui-mobile .sheet:not(.pdfmode) table.kv td.lab { font-size: 14px; margin-bottom: 4px; }
body.ui-mobile .sheet:not(.pdfmode) .tablewrap table.grid { min-width: 0; border: 0; }
body.ui-mobile .sheet:not(.pdfmode) table.grid, body.ui-mobile .sheet:not(.pdfmode) table.grid tbody,
body.ui-mobile .sheet:not(.pdfmode) table.grid tr, body.ui-mobile .sheet:not(.pdfmode) table.grid td { display: block; width: 100%; }
body.ui-mobile .sheet:not(.pdfmode) table.grid tr:first-child { display: none; }
body.ui-mobile .sheet:not(.pdfmode) table.grid tr { border: 1px solid #e3e8ee; border-radius: 10px; padding: 10px 12px 6px; margin: 0 0 10px; position: relative; }
body.ui-mobile .sheet:not(.pdfmode) table.grid tr::before { content: attr(data-rowlabel); display: block; font-weight: bold; color: var(--ui-accent); margin-bottom: 6px; }
body.ui-mobile .sheet:not(.pdfmode) table.grid td { border: 0; height: auto; padding: 0 0 8px; }
body.ui-mobile .sheet:not(.pdfmode) table.grid td::before { content: attr(data-label); display: block; font-size: 12.5px; font-weight: bold; color: #475569; margin-bottom: 3px; }
body.ui-mobile .sheet:not(.pdfmode) table.grid td.fixed { font-weight: bold; padding-bottom: 6px; }
body.ui-mobile .sheet:not(.pdfmode) table.grid td.fixed::before { display: none; }
body.ui-mobile .sheet:not(.pdfmode) table.grid .f { border: 1px solid var(--ui-line); border-radius: 6px; min-height: 40px; }
body.ui-mobile .sheet:not(.pdfmode) table.grid .rm { position: absolute; right: 8px; top: 8px; }
body.ui-mobile .sheet:not(.pdfmode) table.yesno, body.ui-mobile .sheet:not(.pdfmode) table.yesno tbody,
body.ui-mobile .sheet:not(.pdfmode) table.yesno tr, body.ui-mobile .sheet:not(.pdfmode) table.yesno td { display: block; width: 100%; }
body.ui-mobile .sheet:not(.pdfmode) table.yesno td { border: 0; padding: 4px 0; }
body.ui-mobile .sheet:not(.pdfmode) table.yesno tr { border-bottom: 1px solid #eef1f5; padding: 8px 0; }
body.ui-mobile .sheet:not(.pdfmode) table.yesno tr:first-child { display: none; }
#ui-bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff; box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
#ui-bottombar .ui-bb-txt { flex: 1; font-size: 13px; color: var(--ui-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ui-mobile { padding-bottom: 70px; }

@media print { #ui-nav, #ui-progress, #ui-stepper, .ui-stepnav, #ui-bottombar, .ui-continue, .ui-pill, .ui-chev { display: none !important; } .ui-off, section.ui-closed > * { display: revert !important; } }

/* the PDF copy always uses the sheet's own text size, whatever layout the client used */
body.ui .sheet.pdfmode { font-size: 13px; }

/* ======================================================================= colour & font themes (?theme=)
   brand = their website (Inter / Inter Tight, #1D2128 + red #E40046) · brandblue = logo blue #4058A8 · classic = today + logo.
   The PDF copy is pinned to the sheet's Arial whatever the theme. */
body.ui .sheet.pdfmode, body.ui .sheet.pdfmode * { font-family: Arial, Helvetica, sans-serif !important; }
.ui-logo { display: block; height: 52px; width: auto; margin: 0 auto 8px; }
.sheet:not(.pdfmode) .letterhead.has-logo .lh-name { display: none; }

body.theme-brand, body.theme-brandblue { font-family: "Inter", Arial, Helvetica, sans-serif; }
:is(.theme-brand, .theme-brandblue) .sheet:not(.pdfmode) .sec-title,
:is(.theme-brand, .theme-brandblue) .sheet:not(.pdfmode) .banner,
:is(.theme-brand, .theme-brandblue) #ui-stepper .ui-step-t,
:is(.theme-brand, .theme-brandblue) .sheet:not(.pdfmode) .lh-title { font-family: "Inter Tight", "Inter", Arial, sans-serif; letter-spacing: .2px; }
:is(.theme-brand, .theme-brandblue) .toolbar { background: #1D2128; }
:is(.theme-brand, .theme-brandblue) .submit { background: var(--ui-accent); }

body.theme-brand { --ui-accent: #E40046; --ui-accent-soft: #fde8ef; --ui-bg: #F9F9FA; --ui-ink: #1D2128; --ui-line: #E2E5EA; --ui-muted: #80818E; }
body.theme-brand #ui-progress > i { background: #5B74F6; }
body.theme-brand .sheet:not(.pdfmode) .sec-title { color: #1D2128; }
body.theme-brand .sheet:not(.pdfmode) .sec-title::before { content: ""; display: inline-block; width: 4px; height: 1em; background: #E40046; border-radius: 2px; margin-right: 8px; vertical-align: -2px; }

body.theme-brandblue { --ui-accent: #4058A8; --ui-accent-soft: #e9edf8; --ui-bg: #F4F6FB; --ui-ink: #1D2128; --ui-line: #DDE2EC; --ui-muted: #6B7280; }
body.theme-brandblue #ui-progress > i { background: #4058A8; }
body.theme-brandblue .sheet:not(.pdfmode) .sec-title { border-left: 4px solid #D01820; padding-left: 10px; }

body.theme-classic .ui-logo { height: 46px; }
