/* Paper look taken from the Word file: Letter page, 0.5in side margins, Arial 9.5pt,
   black 1px table rules, bold uppercase headings with a rule under them, italic-bold notes. */
:root {
  --ink: #000;
  --rule: #3a3a3a;
  --muted: #555;
  --paper: #fff;
  --desk: #e9eaec;
  --fill: #f3f7ff;
  --focus: #2b62d9;
  --err: #c2261d;
  --errbg: #fff3f2;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--desk); color: var(--ink);
  font: 13px/1.35 Arial, "Helvetica Neue", Helvetica, sans-serif;
}

/* ---------- toolbar (screen only, not part of the paper) */
.toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: #1f2937; color: #e5e7eb; font-size: 12.5px;
}
.tb-name { font-weight: bold; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved { color: #9ca3af; white-space: nowrap; }
.tb-btn {
  font: inherit; border: 1px solid #6b7280; background: transparent; color: inherit;
  padding: 5px 10px; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.tb-btn:hover { background: #374151; }

/* ---------- the sheet */
.sheet {
  width: 8.5in; max-width: 100%; margin: 24px auto; background: var(--paper);
  padding: 0.6in 0.5in 0.4in; box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 6px 24px rgba(0,0,0,.08);
}
.letterhead { text-align: center; margin-bottom: 22px; }
.lh-name { font-weight: bold; }
.lh-title { font-weight: bold; margin-top: 12px; }

section.sec { margin: 0 0 22px; }
section.sec[hidden] { display: none; }
.sec-title {
  font-weight: bold; margin: 0 0 8px; padding-bottom: 3px; border-bottom: 1.5px solid var(--rule);
  font-size: 13px;
}
.banner { text-align: center; font-weight: bold; font-size: 18px; margin: 34px 0 10px; }

p.note { margin: 6px 0 8px; }
p.note.b { font-weight: bold; }
p.note.i { font-style: italic; }
p.note.bi { font-weight: bold; font-style: italic; }

/* ---------- tables */
table.t { width: 100%; border-collapse: collapse; margin: 6px 0 4px; table-layout: fixed; }
table.t td, table.t th {
  border: 1px solid var(--ink); padding: 6px 7px; vertical-align: top; text-align: left;
}
table.t th { font-weight: bold; }
table.kv td.lab { width: 36%; font-weight: bold; }
table.kv td.lab .sub { display: block; font-weight: normal; font-size: 10px; margin-top: 1px; }
table.kv td.span { font-weight: bold; }
table.docs td.box { width: 7%; text-align: center; }
table.yesno td.ans { width: 22%; white-space: nowrap; }
.tablewrap { width: 100%; overflow-x: auto; }
.tablewrap table.grid { min-width: 560px; }
table.grid td { padding: 0; height: 34px; }
table.grid td.fixed { padding: 6px 7px; }
table.grid tr.extra td:last-child { position: relative; }

/* ---------- inputs: invisible until used, so the page still reads as their sheet */
.f {
  font: inherit; color: inherit; width: 100%; border: 0; background: transparent;
  padding: 2px 3px; border-radius: 2px; min-height: 22px;
}
table.grid .f { height: 100%; min-height: 34px; padding: 6px 7px; }
.f:hover { background: var(--fill); }
.f:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--fill); }
textarea.f { resize: vertical; min-height: 44px; display: block; }
textarea.lined {
  border-radius: 0; padding: 0 3px; line-height: 26px; min-height: 56px;
  background: repeating-linear-gradient(transparent 0 25px, #000 25px 26px);
}
.line {
  display: inline-block; border: 0; border-bottom: 1px solid var(--ink); width: 150px;
  min-height: 20px; padding: 1px 3px; border-radius: 0; vertical-align: baseline;
}
.line.wide { width: 300px; max-width: 100%; }
.signrow .part { flex-wrap: nowrap; }
input.line[data-fmt="date"] { width: 110px; }
input.line[data-fmt="month"] { width: 80px; }
.line:focus { outline: 0; border-bottom: 2px solid var(--focus); background: var(--fill); }
.part { display: inline-flex; align-items: baseline; gap: 6px; margin: 2px 22px 2px 0; flex-wrap: wrap; }
.then { display: block; margin-top: 6px; }
.then[hidden] { display: none; }

.opts { display: inline-flex; flex-wrap: wrap; gap: 4px 18px; }
.opt { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-weight: normal; }
.opt input { margin: 0; width: 13px; height: 13px; accent-color: #222; cursor: pointer; }
.radioline { margin: 6px 0 8px; }
.radioline .rl-label { margin-right: 10px; }
.radioline.b .rl-label { font-weight: bold; }

.docsub { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 10px 0 2px 10px; }
.docsub .dl { font-weight: bold; }
.docbox { width: 14px; height: 14px; accent-color: #222; margin: 0; cursor: pointer; }

.declare { display: flex; gap: 8px; align-items: flex-start; font-weight: bold; margin: 10px 0 14px; cursor: pointer; }
.declare input { margin-top: 2px; width: 14px; height: 14px; accent-color: #222; }
.signrow { margin: 10px 0; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 40px; }
.sigwrap { display: inline-flex; align-items: flex-end; gap: 6px; }
.sigpad {
  width: 260px; height: 64px; border-bottom: 1px solid var(--ink); touch-action: none; cursor: crosshair;
  background: linear-gradient(transparent, transparent);
}
.sigpad:hover { background: var(--fill); }
.sigclear { font: inherit; font-size: 11px; background: none; border: 0; color: var(--focus); cursor: pointer; padding: 0 0 4px; }

.addrow {
  font: inherit; font-size: 12px; margin: 4px 0 0; padding: 4px 9px; border: 1px dashed #888;
  background: #fafafa; border-radius: 3px; cursor: pointer; color: #222;
}
.addrow:hover { background: #f0f0f0; }
.rm {
  position: absolute; right: -24px; top: 7px; width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: #eee; color: #555; cursor: pointer; font-size: 13px; line-height: 20px; padding: 0;
}
.rm:hover { background: #fdd; color: var(--err); }
.period-title { font-weight: bold; margin: 14px 0 2px; display: flex; justify-content: space-between; align-items: center; }
.period-title .rm { position: static; }

/* ---------- required state */
.err { background: var(--errbg) !important; box-shadow: inset 0 0 0 1.5px var(--err); }
.errors {
  border: 1px solid var(--err); background: var(--errbg); color: var(--err); padding: 10px 12px;
  margin: 0 0 12px; border-radius: 4px; font-size: 12.5px;
}
.errors a { color: var(--err); }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

.actions { margin-top: 28px; }
.submit {
  font: inherit; font-weight: bold; background: #1f2937; color: #fff; border: 0; border-radius: 4px;
  padding: 10px 22px; cursor: pointer;
}
.submit:hover { background: #111827; }
.pagefoot { text-align: right; font-size: 11px; margin-top: 36px; color: var(--ink); }

/* ---------- submitted dialog */
.done { position: fixed; inset: 0; background: rgba(17,24,39,.55); display: grid; place-items: center; padding: 16px; z-index: 10; }
.done[hidden] { display: none; }
.done-card { background: #fff; max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; border-radius: 8px; padding: 22px; }
.done-card h2 { margin: 0 0 8px; font-size: 18px; }
.done-label { font-weight: bold; margin-bottom: 4px; }
.done pre { background: #f5f5f5; padding: 10px; font-size: 11.5px; white-space: pre-wrap; word-break: break-word; border-radius: 4px; }
.done-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.done-btns .tb-btn { color: #1f2937; border-color: #9ca3af; }

/* ---------- the copy the PDF is drawn from (off screen): answers as plain text, boxes drawn */
.pdfmode { width: auto; margin: 0; padding: 0; box-shadow: none; }
.pdfmode .pv { display: block; min-height: 18px; padding: 2px 3px; white-space: pre-wrap; word-break: break-word; }
.pdfmode table.grid .pv { padding: 6px 7px; min-height: 34px; }
.pdfmode .pv.line { display: inline-block; min-width: 150px; border-bottom: 1px solid #000; padding: 1px 3px; min-height: 18px; vertical-align: baseline; }
.pdfmode .pv.line.wide { min-width: 300px; }
.pdfmode .pv-ta { min-height: 40px; }
.pdfmode .pv-ta.lined { border-bottom: 1px solid #000; min-height: 52px; }
.pdfmode .pv-radio, .pdfmode .pv-check { display: inline-block; width: 12px; height: 12px; border: 1px solid #333; vertical-align: -2px; background: #fff; flex: none; }
.pdfmode .pv-radio { border-radius: 50%; }
.pdfmode .pv-radio.on { background: radial-gradient(circle, #111 0 3px, #fff 3.5px); }
.pdfmode .pv-check { position: relative; }
.pdfmode .pv-check.on::after {
  content: ""; position: absolute; left: 3px; top: 0; width: 4px; height: 8px;
  border: solid #111; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.pdfmode .pv-sig { width: 260px; height: 64px; border-bottom: 1px solid #000; object-fit: contain; object-position: left bottom; }
.pdfmode .docbox { display: none; }

/* ---------- phone width */
@media (max-width: 720px) {
  .sheet { margin: 0; padding: 22px 16px; box-shadow: none; }
  body { background: var(--paper); }
  table.kv td.lab { width: 42%; }
  .rm { right: 2px; top: 2px; }
  .sigpad { width: 220px; }
  .saved { display: none; }
}

/* ---------- print / PDF: exactly the paper, nothing from the screen UI */
/* the page footer text is injected by app.js per type (Chrome has no string-set) */
@page { size: letter; margin: 0.55in 0.5in 0.6in; }
@media print {
  body { background: #fff; font-size: 9.5pt; }
  .toolbar, .actions, .addrow, .rm, .sigclear, .done, .pagefoot { display: none !important; }
  .sheet { width: auto; margin: 0; padding: 0; box-shadow: none; }
  .f, .line { background-color: transparent !important; }
  textarea.lined { background: none !important; border-bottom: 1px solid #000; min-height: 52px; }
  .f::placeholder, .line::placeholder { color: transparent; }
  textarea.f { resize: none; overflow: hidden; }
  .sigpad { background: none !important; }
  tr, .radioline, .signrow, .declare { break-inside: avoid; }
  .sec-title, .banner { break-after: avoid; }
  .banner { break-before: page; }
  .err { background: none !important; box-shadow: none; }
}
