:root {
  --paper: #f2eee2;
  --card: #ebe5d5;
  --card-light: #faf7ef;
  --line: #d6cfbb;
  --green: #2c5140;
  --gold: #a08440;
  --gold-fill: #b99c57;
  --ink: #26241f;
  --muted: #7a766a;
  --serif: "Besley", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: #dcd7c8;
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 100vh;
}

/* ---------- control panel ---------- */
.panel {
  background: #fbf9f3;
  border-right: 1px solid var(--line);
  padding: 22px 22px 40px;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}
.panel-brand img { display: block; height: 44px; width: auto; }
.mark { width: 24px; height: 24px; fill: var(--green); flex: none; }
.panel-lede { margin: 6px 0 18px; font-size: 13px; color: var(--muted); }

.panel label { display: block; font-size: 11.5px; font-weight: 600; color: var(--green); margin-bottom: 10px; }
.panel input, .panel select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  font: 14px var(--sans); color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
}
.panel input:focus, .panel select:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 14px 0 0; padding: 14px 0 0; }
legend { padding: 0 8px 0 0; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 700; }

.lookup-row { display: flex; gap: 8px; }
.lookup-row input { margin-top: 4px; }
button {
  font: 600 14px var(--sans); cursor: pointer; border-radius: 6px;
  border: 1px solid var(--green); background: #fff; color: var(--green); padding: 8px 14px;
}
.lookup-row button { margin-top: 4px; flex: none; }
button.primary { width: 100%; background: var(--green); color: #fff; padding: 12px; }
button.secondary { width: 100%; margin-top: 8px; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .6; cursor: wait; }
.panel label.shot { margin: 10px 0 0; padding: 12px; text-align: center; font-weight: 400; font-size: 12px; line-height: 1.5; color: var(--muted); border: 1.5px dashed var(--line); border-radius: 6px; cursor: pointer; }
.panel label.shot b { color: var(--green); }
.panel label.shot:hover, .panel label.shot.over { border-color: var(--gold); background: #fff; }
.panel label.shot.busy { opacity: .6; cursor: wait; }
.note { font-size: 12.5px; line-height: 1.45; margin: 8px 0 0; padding: 9px 11px; border-radius: 6px; background: #fbefd2; border: 1px solid #e9d7a3; color: #5d4a17; }
.note.good { background: #e6f0e8; border-color: #bcd3c2; color: var(--green); }
.actions { margin-top: 20px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 8px 0 0; }

/* ---------- document ---------- */
.preview { padding: 28px; overflow-x: auto; }
.empty { max-width: 520px; margin: 18vh auto 0; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.6; }
.empty h2 { font-family: var(--serif); color: var(--green); font-weight: 600; margin: 0 0 8px; }

.page {
  width: 816px; height: 1056px; margin: 0 auto 24px;
  padding: 54px 86px 0;
  background: var(--paper);
  box-shadow: 0 2px 14px rgba(40, 35, 20, .18);
  position: relative; overflow: hidden;
  font-size: 13.5px; line-height: 1.6;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.page p { margin: 0 0 10px; }

.head { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 8px; border-bottom: 2px solid; border-image: linear-gradient(90deg, var(--gold), transparent) 1; margin-bottom: 16px; }
.brand img { display: block; height: 34px; width: auto; }
.head-right { text-align: right; }
.eyebrow { font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.head-title { font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--green); line-height: 1.35; }
.head-sub { font-size: 11.5px; color: var(--gold); }

.foot { margin-top: 24px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.foot .mark { width: 14px; height: 14px; opacity: .8; }

.card { background: var(--card); border: 1px solid var(--line); padding: 16px 20px; }
.label { font-size: 9.5px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--green); }
.label.gold { color: var(--gold); }
.address { font-family: var(--serif); font-weight: 700; font-size: 23px; line-height: 1.3; margin: 2px 0; }
.card em, .tile em { font-size: 11.5px; color: var(--muted); }
.salutation { font-family: var(--serif); font-size: 17px; margin: 20px 0 6px; }

.terms { width: 100%; border-collapse: collapse; border: 1px solid var(--line); margin-top: 16px; }
.terms caption { text-align: left; background: var(--card); border: 1px solid var(--line); border-bottom: 2px solid var(--line); padding: 9px 16px; font-family: var(--serif); font-size: 14px; color: var(--green); }
.terms caption .label { margin-right: 8px; }
.terms th, .terms td { text-align: left; vertical-align: top; padding: 6px 15px; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.45; }
.terms th { width: 165px; font-size: 11px; font-weight: 700; color: var(--green); text-transform: uppercase; background: var(--card); }
.terms tr:nth-child(odd) td { background: transparent; }
.terms tr:nth-child(even) td { background: var(--card-light); }
.terms tr:nth-child(even) th { background: #efece2; }
.terms b, .payoff-rows b { font-family: var(--serif); font-weight: 600; font-size: 13px; }

.plain { margin-top: 15px; }
.plain p { font-size: 14px; line-height: 1.7; margin: 6px 0 0; }
.plain strong { font-family: var(--serif); font-size: 19px; color: var(--gold); }

h3 { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--green); margin: 22px 0 8px; }
.callout { margin: 14px 0; font-size: 14px; }
.callout strong { color: var(--green); }
.callout.warm { background: #fbefd2; border-color: #ead9ab; font-size: 12.5px; }
.callout.warm strong { color: var(--gold); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { padding: 4px 0 4px 26px; position: relative; }
.checks li::before { content: "✓"; position: absolute; left: 0; top: 7px; width: 12px; height: 12px; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold); font-size: 8px; line-height: 12px; text-align: center; }
.signature { font-family: "Mrs Saint Delafield", "Snell Roundhand", cursive; font-size: 46px; line-height: 1; margin: 6px 0 2px 6px; min-height: 46px; }
.signer { font-family: var(--serif); font-weight: 700; font-size: 16px; color: var(--green); }
.signer-meta { font-size: 11px; color: var(--muted); }

.hero { font-family: var(--serif); font-weight: 700; font-size: 37px; line-height: 1.15; color: var(--green); margin: 6px 0 8px; }
.locale { font-size: 12px; color: var(--muted); }
.structure { font-size: 12px; font-weight: 600; color: var(--green); margin: 4px 0; }
.tagline { font-family: var(--serif); font-style: italic; font-size: 17px; line-height: 1.4; margin: 6px 0 18px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-width: 1px 0 0 1px; }
.tile { background: var(--card-light); border: 1px solid var(--line); border-width: 0 1px 1px 0; padding: 14px 15px 16px; }
.tile .label { color: var(--muted); font-size: 8.5px; }
.tile .num { font-family: var(--serif); font-weight: 700; font-size: 21px; margin: 4px 0 2px; }
.tile em { font-size: 9.5px; display: block; }
.tile.soft { background: var(--card); }
.tile.soft .label { color: var(--green); }
.tile.soft .num { color: var(--gold); }
.tile.strong { background: var(--gold-fill); }
.tile.strong .label, .tile.strong em { color: var(--ink); }
.tile.strong .num { color: var(--green); }

.sched { width: 100%; border-collapse: collapse; font-size: 10.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.sched th { background: var(--card); border-bottom: 2px solid var(--gold); padding: 7px 8px; font-weight: 600; color: var(--green); text-align: right; }
.sched td { padding: 3.7px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.sched th:nth-child(1), .sched td:nth-child(1) { text-align: center; width: 38px; color: var(--muted); }
.sched th:nth-child(2), .sched td:nth-child(2) { text-align: left; }
.sched th:nth-child(1) { color: var(--green); }

.payoff { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); }
.payoff-left { background: var(--card); padding: 24px; border-right: 1px solid var(--line); }
.payoff-left h2 { font-family: var(--serif); font-weight: 700; font-size: 27px; color: var(--green); margin: 6px 0 2px; }
.payoff-big { font-family: var(--serif); font-weight: 700; font-size: 42px; line-height: 1.1; color: var(--gold); }
.payoff-right { background: var(--card-light); padding: 20px 22px; }
.payoff-right h3 { margin: 0 0 10px; }
.payoff-rows { margin: 0; }
.payoff-rows div { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.payoff-rows dt, .payoff-rows dd { margin: 0; }
.payoff-rows b { font-size: 15px; }
.payoff-rows .total { border-top: 2px solid var(--gold); border-bottom: 0; margin-top: 3px; padding-top: 12px; font-weight: 600; color: var(--green); }
.payoff-rows .total b { color: var(--gold); font-size: 17px; }
.closing-line { font-family: var(--serif); font-style: italic; font-size: 23px; color: var(--green); text-align: center; margin: 26px 0 2px; }
.center { text-align: center; }
.fine { font-size: 9px; font-style: italic; color: var(--muted); line-height: 1.6; margin-top: 18px !important; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  body { display: block; }
  .panel { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 16px 24px; }
  .preview { padding: 16px; }
}

/* ---------- print ---------- */
@page { size: letter; margin: 0; }
@media print {
  body { display: block; background: none; }
  .panel, .empty { display: none !important; }
  .preview { padding: 0; overflow: visible; }
  .page { margin: 0; box-shadow: none; width: 8.5in; height: 11in; break-after: page; }
  .page:last-child { break-after: auto; }
}
.panel input[hidden] { display: none; }
.panel input:disabled { background: #f1eee6; color: var(--muted); }
