:root {
  /* Enriched brand (enrichedbushels.com) */
  --navy: #0d1b2a;
  --navy-dark: #050d16;
  --gold: #c8a15a;
  --gold-text: #7a5a1e; /* gold dark enough for text on light backgrounds */
  --cream: #f6f1e8;
  --gold-bg: #f8efdc; /* pale gold for notices */
  --serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  /* meaning colours */
  --ok: #2f6b3a;
  --ok-bg: #e8f2ea;
  --ink: #0d1b2a;
  --muted: #4a5568;
  --line: #d6d0c4;
  --bg: #faf8f3;
  --card: #ffffff;
  --amber: #8a5a00;
  --amber-bg: #fff4dc;
  --red: #a3221a;
  --red-bg: #fdecea;
  --focus: #1a5fb4;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

.skip-link { position: absolute; left: -999px; top: 0; background: var(--card); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; }

.app { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }

h1, h2, h3, .status-label { font-family: var(--serif); color: var(--navy); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.75rem 0 0.5rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
h1:focus { outline: none; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* header and progress */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 0; border-bottom: 3px solid var(--gold); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0; min-width: 0; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-title { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; color: var(--navy); border-left: 2px solid var(--gold); padding-left: 12px; line-height: 1.2; }
.status-chip { display: inline-block; font-size: 0.85rem; padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor; }
.status-missing { color: var(--amber); background: var(--amber-bg); }
.status-expert { color: #5b3c88; background: #f1ebfa; }
.status-prepared { color: var(--ok); background: var(--ok-bg); }

.progress { margin: 16px 0 8px; }
.progress-text { margin: 0 0 6px; font-weight: 600; color: var(--muted); font-size: 0.95rem; }
.progress-bar { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-bar::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
.progress-bar::-webkit-progress-value { background: var(--gold); border-radius: 999px; }
.progress-bar::-moz-progress-bar { background: var(--gold); border-radius: 999px; }
.progress ol { list-style: none; display: flex; gap: 4px; padding: 0; margin: 8px 0 0; overflow-x: auto; }
.progress li { flex: 1 1 0; min-width: 0; }
.progress-step { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; padding: 6px 2px; cursor: pointer; color: var(--muted); font: inherit; font-size: 0.8rem; min-height: 44px; }
.progress-num { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; border: 2px solid var(--line); background: var(--card); font-weight: 700; }
.progress-step[aria-current="step"] { color: var(--ink); font-weight: 700; }
.progress-step[aria-current="step"] .progress-num { border-color: var(--navy); background: var(--navy); color: #fff; }
.progress-name { display: none; text-align: center; }
@media (min-width: 720px) { .progress-name { display: block; } }

/* layout */
.layout { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .helper { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
  .skip-help { display: none; }
}
.step { min-width: 0; }

/* form controls */
.field { margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
label, legend { display: block; font-weight: 600; margin-bottom: 4px; }
legend { padding: 0; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 6px; }
input[type="text"], input[type="email"], input[type="date"], select, textarea {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 12px; min-height: 52px;
  border: 2px solid #8a958d; border-radius: 8px; background: var(--card); color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input[aria-invalid="true"] { border-color: var(--red); background: var(--red-bg); }
.error-text { color: var(--red); font-weight: 600; margin: 4px 0 0; font-size: 0.95rem; }
.error-text:empty { display: none; }
.warn-text { color: var(--amber); font-weight: 600; margin: 4px 0 8px; }
.ok-text { color: var(--ok); margin: 4px 0 8px; }

.choice { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; margin: 6px 0; background: var(--card); border: 2px solid var(--line); border-radius: 8px; }
.choice:has(input:checked) { border-color: var(--navy); background: var(--cream); }
.choice input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; accent-color: var(--navy); }
.choice label { font-weight: 500; margin: 0; flex: 1; cursor: pointer; }
.choice-title { display: block; font-weight: 600; }
.choice-desc { display: block; color: var(--muted); font-size: 0.92rem; }
.check { margin-top: 8px; }

.row-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 600px) {
  .row-grid { grid-template-columns: 1fr 1fr; }
  .row-grid.three { grid-template-columns: 1fr 1fr 1fr; }
}
.row-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; align-items: end; }
.row-grid.compact label { font-size: 0.9rem; }
.row-grid.compact input { padding: 10px 8px; }
.row-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.row-title { font-weight: 700; margin: 0 0 8px; }
.subhead { font-weight: 700; margin: 12px 0 4px; }
.category { border-top: 1px solid var(--line); padding-top: 4px; }
.subsection { margin-top: 8px; }
.total-line p, .subtotal p { margin: 8px 0; }

/* buttons */
.btn { font: inherit; font-weight: 600; min-height: 48px; padding: 10px 18px; border-radius: 8px; border: 2px solid var(--navy); cursor: pointer; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: var(--card); color: var(--navy); }
.btn-link { background: none; border-color: transparent; color: var(--navy); text-decoration: underline; padding-left: 0; }
.btn-large { font-size: 1.1rem; min-height: 56px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.nav-buttons { display: flex; justify-content: space-between; gap: 12px; margin: 28px 0 8px; position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }
.nav-buttons .btn { flex: 1; max-width: 240px; }
.nav-buttons .btn-primary { margin-left: auto; }
.actions, .start-actions { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
@media (min-width: 600px) { .actions, .start-actions { flex-direction: row; flex-wrap: wrap; } }

/* notes, flags, notices */
.note { background: var(--card); border-left: 4px solid var(--gold); padding: 10px 14px; margin: 12px 0; font-size: 0.95rem; }
.units-note p { margin: 4px 0; }
.lead { font-size: 1.15rem; }
.flag { border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; border: 2px solid; }
.flag h2 { margin: 0 0 6px; font-size: 1.05rem; }
.flag p { margin: 4px 0; }
.flag-timing { border-color: var(--red); background: var(--red-bg); }
.flag-doc { border-color: var(--amber); background: var(--amber-bg); }
.flag-missing { border-color: var(--amber); background: var(--amber-bg); }
.notice { border-radius: var(--radius); padding: 8px 14px; margin: 12px 0; border: 2px solid var(--navy); background: var(--cream); }
.notice-alert { border-color: var(--red); background: var(--red-bg); }
.notice p { margin: 4px 0; }
.error-summary { border: 3px solid var(--red); background: var(--red-bg); border-radius: var(--radius); padding: 8px 16px; margin: 12px 0; }
.error-summary h2 { margin: 4px 0; }
.error-summary a { color: var(--red); font-weight: 600; }

/* helper */
.helper { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 12px; }
.helper h2 { margin-top: 12px; }
.helper details { border-top: 1px solid var(--line); padding: 6px 0; }
.helper summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.helper dt { font-weight: 600; margin-top: 8px; }
.helper dd { margin: 0 0 4px; color: var(--muted); font-size: 0.95rem; }
.helper ul { padding-left: 20px; margin: 4px 0; font-size: 0.95rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
.group-box { background: var(--card); border: 2px solid var(--navy); border-radius: var(--radius); padding: 4px 14px 8px; margin: 12px 0 18px; }
.group-box h3 { margin-top: 8px; }
details.optional { margin: 8px 0 14px; border: 1px dashed var(--line); border-radius: 8px; padding: 4px 12px; background: var(--card); }
details.optional > summary { cursor: pointer; font-weight: 600; color: var(--navy); min-height: 44px; display: flex; align-items: center; }
details.optional[open] > summary { margin-bottom: 8px; }
.warn-list { color: var(--amber); font-weight: 600; margin: 4px 0 8px; padding-left: 20px; }
.manure-applied p { margin: 4px 0 12px; }
.expert-criteria { margin: 16px 0 0; font-size: 0.95rem; }

.header-side { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.header-email { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.email-screen, .saved-screen { max-width: 640px; }
.email-form .actions { align-items: center; }
#save-code { max-width: 12em; letter-spacing: 0.3em; font-size: 1.3rem; }
.saved-list { list-style: none; padding: 0; margin: 12px 0; }
.saved-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0; }
.saved-item p { margin: 2px 0; }
.saved-name { font-weight: 700; overflow-wrap: anywhere; }
.saved-actions { display: flex; gap: 8px; align-items: center; }

.label-like { font-weight: 600; margin: 0 0 4px; }
.static-value { margin: 0; padding: 12px 0; font-size: 1.05rem; }
.row-card.source legend, .row-card.manure-details legend { padding: 0 4px; }
.basis-line { font-size: 1.05rem; white-space: pre-wrap; }
.record-sub { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 400; font-size: 0.85rem; color: var(--muted); }
table.budget th[scope="row"] { font-weight: 600; }
table.budget thead th { overflow-wrap: normal; }
table.budget thead th:nth-child(n+6), table.budget td:nth-child(n+6) { white-space: nowrap; }
table.budget tr.unused td, table.budget tr.unused th { color: var(--muted); }
.cert-text { font-size: 0.95rem; background: var(--cream); padding: 10px 14px; border-radius: 8px; }

.e-signatures { display: grid; gap: 8px; margin: 10px 0; }
.e-signature { border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 6px; padding: 6px 12px; background: var(--card); }
.e-signature p { margin: 2px 0; }
.e-sig-name { font-family: var(--serif); font-weight: 700; }
.e-sig-detail { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.e-sig-pending { color: var(--amber); font-weight: 600; }
.advisor-statement { white-space: pre-wrap; }
.status-signed { color: var(--ok); background: var(--ok-bg); }
.status-awaiting { color: #5b3c88; background: #f1ebfa; }
.status-declined { color: var(--red); background: var(--red-bg); }
.sign-panel { background: var(--card); border: 2px solid var(--navy); border-radius: var(--radius); padding: 4px 16px 12px; margin: 16px 0; }
.adviser-found { background: var(--cream); border-radius: 8px; padding: 8px 12px; }

.header-link { min-height: 36px; padding: 4px 6px; font-size: 0.9rem; }
.adviser-entry { margin-top: 20px; color: var(--muted); }
fieldset.locked { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.locked input, fieldset.locked select, fieldset.locked textarea { background: #f1efe9; }
.saved-signing { font-weight: 600; margin: 2px 0; }
.signing-signed { color: var(--ok); }
.signing-awaiting_adviser { color: #5b3c88; }
.signing-declined { color: var(--red); }

.independence { font-size: 0.9rem; margin: 10px 0 0; }
.status-ready { color: var(--ok); background: var(--ok-bg); }
.removals .radio-group, .manure .radio-group { margin-bottom: 8px; }

.field-guide { background: var(--cream); border-left: 4px solid var(--gold); border-radius: 8px; padding: 6px 12px 8px; margin: 8px 0 12px; font-size: 0.95rem; }
.field-guide h3 { margin: 4px 0 6px; font-size: 1rem; }
.field-guide p, .inline-guide p { margin: 4px 0; }
.guide-note { font-weight: 600; color: var(--navy); }
.inline-guide { background: var(--cream); border-left: 4px solid var(--gold); border-radius: 6px; padding: 4px 10px; margin: -8px 0 16px; font-size: 0.9rem; }
@media (min-width: 960px) { .inline-guide { display: none; } }

/* plan document (review and print) */
.plan-doc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 18px 16px; }
.status-label { font-weight: 700; font-size: 1.1rem; padding: 10px 14px; border-radius: 8px; border: 2px solid currentColor; display: inline-block; }
.doc-section { border-top: 1px solid var(--line); margin-top: 16px; }
.doc-dl { display: grid; grid-template-columns: 1fr; margin: 8px 0; }
.doc-dl dt { font-weight: 600; color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.doc-dl dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
@media (min-width: 600px) {
  .doc-dl { grid-template-columns: minmax(180px, 34%) 1fr; gap: 4px 16px; }
  .doc-dl dt { margin-top: 0; }
}
.doc-row { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin: 8px 0; }
.doc-row-title { font-weight: 700; margin: 4px 0; }
.missing-value { color: var(--amber); font-style: italic; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.95rem; }
caption { text-align: left; font-size: 0.9rem; color: var(--muted); padding-bottom: 4px; }
th, td { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
table.totals { table-layout: fixed; }
.plan-doc { min-width: 0; }
thead th { background: var(--cream); }
tr.difference th, tr.difference td { font-weight: 600; background: #f4f4f1; }
.write-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 18px 0 0; }
.write-label { flex: 0 1 auto; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.write-space { flex: 1 1 10em; border-bottom: 1px solid var(--ink); min-height: 1.6em; min-width: 0; overflow-wrap: anywhere; }
.generated { font-size: 0.85rem; color: var(--muted); margin: 4px 0; overflow-wrap: anywhere; }

.print-root { display: none; }

/* print: only the plan document */
@media print {
  /* One Letter page: compact type, grids for short fields, signature lines side by side. */
  @page { size: letter; margin: 8mm 12mm; }
  body { background: #fff; font-size: 8pt; line-height: 1.28; }
  .app, .skip-link { display: none !important; }
  .print-root { display: block; }
  .print-frame, .print-frame > * > tr > td { border: 0; padding: 0; margin: 0; width: 100%; }
  .print-frame { break-inside: auto; font-size: inherit; }
  .print-frame > tbody > tr { break-inside: auto; }
  thead { display: table-header-group; }
  .running-header { font-size: 7pt; color: #444; border-bottom: 0.5pt solid #999; padding-bottom: 2pt; margin-bottom: 4pt; }

  .plan-doc { border: 0; padding: 0; }
  .doc-brand { display: flex; align-items: center; gap: 8pt; font-family: var(--serif); font-weight: 700; font-size: 9pt; margin: 0; padding-bottom: 3pt; border-bottom: 1.5pt solid var(--gold); }
  .doc-logo { height: 16pt; width: auto; }
  .doc-header h1 { font-size: 12pt; margin: 2pt 0 0; }
  .record-intro { margin: 1pt 0 3pt; font-size: 8pt; }
  .status-label { display: inline-block; font-size: 8.5pt; padding: 1pt 6pt; margin: 2pt 0; border: 1pt solid #000; border-radius: 3pt; color: #000; background: none; }
  .plan-doc > .note { display: none; }
  .flag { margin: 3pt 0; padding: 2pt 6pt; border-radius: 3pt; break-inside: avoid; }
  .flag h2 { font-size: 8.5pt; margin: 0; display: inline; }
  .flag p { display: inline; margin: 0 0 0 4pt; }
  .flag ul { display: inline; margin: 0; padding: 0; }
  .flag li { display: inline; }
  .flag li + li::before { content: " · "; }
  .flag-doc, .flag-missing { border: 1pt solid #000; background: none; }
  .missing-value { color: #000; font-style: italic; }

  .doc-section { border-top: 0.75pt solid #999; margin-top: 3pt; padding-top: 1pt; }
  h2, .record-head { font-size: 9.5pt; margin: 2pt 0 2pt; break-after: avoid; }
  .record-sub { font-size: 7.5pt; }
  .doc-dl { margin: 1pt 0; gap: 1pt 6pt; }
  .doc-dl dt { margin: 0; font-size: 7.5pt; color: #444; }
  .doc-dl dd { margin: 0; }
  .doc-dl.grid3 { grid-template-columns: max-content 1fr max-content 1fr max-content 1fr; }
  .doc-dl.grid4 { grid-template-columns: max-content 1fr max-content 1fr max-content 1fr max-content 1fr; }
  .basis-line { margin: 1pt 0; font-size: 9pt; }
  .note { font-size: 7.5pt; margin: 2pt 0; padding: 0 0 0 4pt; border-left: 2pt solid var(--gold); background: none; }

  .table-wrap { overflow: visible; }
  table { margin: 2pt 0; }
  table.budget { table-layout: fixed; font-size: 7pt; break-inside: avoid; }
  table.budget th, table.budget td { padding: 1pt 3pt; overflow-wrap: break-word; line-height: 1.2; }
  table.budget thead th { overflow-wrap: normal; background: #eee; }
  table.budget th:nth-child(1) { width: 27%; }
  table.budget th:nth-child(2) { width: 14%; }
  table.budget th:nth-child(3) { width: 7%; }
  table.budget th:nth-child(4) { width: 9%; }
  table.budget th:nth-child(5) { width: 8%; }
  table.budget th:nth-child(n+6) { width: 11.6%; }

  .cert-text { font-size: 7pt; line-height: 1.25; margin: 2pt 0; padding: 2pt 5pt; background: none; border: 0.75pt solid #000; border-radius: 2pt; }
  .write-line { margin-top: 9pt; break-inside: avoid; }
  .write-label { font-size: 7.5pt; }
  .sign-grid { display: grid; grid-template-columns: 2fr 1.2fr 1fr; column-gap: 12pt; }
  .sign-grid .write-line:nth-child(1) { grid-column: span 2; }
  .sign-grid .write-line { display: block; margin-top: 5pt; }
  .sign-grid .write-label { display: block; }
  .sign-grid .write-space { display: block; min-height: 13pt; }
  .advisor-lines .write-line { margin-top: 10pt; }
  .records p { margin: 1pt 0; font-size: 7.5pt; }
  .records .generated { display: inline; font-size: 6.5pt; color: #444; }
  .records .generated + .generated::before { content: " · "; }
  .independence { font-size: 7.5pt; margin: 4pt 0 0; }
  .running-timing { font-weight: 700; margin-left: 8pt; }
  .flag-timing { border: 1.5pt solid #000; background: none; }
  .e-signatures { grid-template-columns: 1fr 1fr; gap: 6pt; margin: 4pt 0; }
  .e-signature { border: 0.75pt solid #000; border-radius: 2pt; padding: 3pt 5pt; }
  .e-sig-name { font-size: 9pt; }
  .e-sig-detail { font-size: 7pt; color: #000; }
}

/* welcome screen: stacked on phones, two columns on wide screens */
.layout.layout-start { grid-template-columns: minmax(0, 1fr); }
.start {
  max-width: 1000px; width: 100%; margin: 24px auto 0;
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: start;
  grid-template-areas: "eyebrow" "head" "intro" "deadline" "card" "why";
}
.start-eyebrow { grid-area: eyebrow; margin: 0 0 6px; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-text); }
.start h1 { grid-area: head; font-family: var(--serif); font-size: clamp(1.8rem, 5vw, 2.3rem); line-height: 1.15; margin: 0 0 14px; }
.start-heading-line { display: block; }
.start-intro { grid-area: intro; margin: 0 0 16px; }
.start-deadline { grid-area: deadline; margin: 0 0 20px; padding: 12px 16px; background: var(--gold-bg); border: 1px solid var(--gold); border-left: 4px solid var(--gold); border-radius: 8px; font-weight: 600; }
.start-card { grid-area: card; align-self: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 3px rgba(13, 27, 42, 0.08); }
.start-card h2 { font-family: var(--serif); font-size: 1.3rem; margin: 0 0 12px; }
.start-card h3 { font-size: 1rem; margin: 0 0 4px; }
.have-ready { padding-left: 1.2em; margin: 0 0 18px; }
.have-ready li { margin: 6px 0; }
.start-primary { display: block; width: 100%; }
.start-secondary { display: block; margin: 6px auto 0; padding-left: 18px; }
.start-save-note { color: var(--muted); margin: 4px 0 0; text-align: center; }
.start-card .adviser-entry { text-align: center; margin-top: 12px; }
.start-why { grid-area: why; margin-top: 24px; }
.start-why h2 { font-size: 1.1rem; margin: 0 0 6px; }
.start-why p { margin: 0; }
@media (min-width: 900px) {
  .start {
    grid-template-columns: minmax(0, 1fr) 380px; column-gap: 64px;
    grid-template-areas: "eyebrow card" "head card" "intro card" "deadline card" "why card";
    grid-template-rows: auto auto auto auto 1fr;
  }
  .start-why { margin-top: 4px; }
}
.brand-link { display: block; border-radius: 4px; }
.home-link { color: var(--navy); font-weight: 600; white-space: nowrap; padding: 6px 2px; }
