:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #667067;
  --forest: #173d2b;
  --forest-2: #285b42;
  --sage: #dce9df;
  --cream: #f4f0e7;
  --paper: #fffdf8;
  --line: #d8d5ca;
  --danger: #9a3e32;
  --shadow: 0 24px 70px rgba(31, 47, 38, .11);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--cream); font: 16px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar { width: min(1180px, calc(100% - 40px)); margin: 0 auto; min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: white; background: var(--forest); font: 700 14px/1 Georgia, serif; letter-spacing: .05em; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 19px/1.15 Georgia, serif; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.docs-link { color: var(--forest); font-weight: 700; text-underline-offset: 4px; }

main { width: min(1100px, calc(100% - 40px)); margin: 0 auto 80px; }
.intro { padding: 84px 0 64px; max-width: 910px; }
.kicker, .step { margin: 0 0 12px; color: var(--forest-2); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, legend { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; max-width: 950px; font-size: clamp(42px, 7vw, 80px); line-height: .98; letter-spacing: -.04em; }
h1 em { color: var(--forest-2); font-weight: 400; }
.lead { max-width: 720px; margin: 30px 0 0; color: #485149; font-size: clamp(18px, 2.4vw, 22px); }
.trust-row { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 32px; color: var(--muted); font-size: 14px; }

.workspace, .result { overflow: hidden; border: 1px solid rgba(23, 61, 43, .13); border-radius: 26px; background: var(--paper); box-shadow: var(--shadow); }
.form-heading, .result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 28px 34px; border-bottom: 1px solid var(--line); }
.form-heading h2, .result-heading h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1; }
.form-heading p:last-child { max-width: 240px; margin: 0; color: var(--muted); font-size: 13px; text-align: right; }
form { padding: 10px 34px 36px; }
.open-report button { margin-top:0; min-height:44px; }
.open-report p { margin:5px 0 0; }
.required-note { margin:18px 34px 0; font-size:12px; color:var(--muted); }
fieldset { margin: 0; padding: 30px 0; border: 0; border-bottom: 1px solid var(--line); }
legend { float: left; width: 180px; padding: 8px 24px 0 0; font-size: 21px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-left: 180px; }
.address-grid { grid-template-columns: 1.5fr .65fr 1fr; }
.wide { grid-column: span 2; }
label { position: relative; display: grid; gap: 7px; color: #3f4941; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid #c9ccc5; border-radius: 11px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(40, 91, 66, .13); }
input::placeholder { color: #9ca19d; }
.field-help { color:var(--muted); font-weight:400; line-height:1.4; }
.unit { position: absolute; right: 14px; bottom: 14px; color: var(--muted); font-weight: 500; }
label:has(.unit) input { padding-right: 42px; }
.checkbox-label { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 12px; border: 1px solid #c9ccc5; border-radius: 11px; background: #fff; }
.checkbox-label input { width: 20px; min-height: 20px; accent-color: var(--forest); }
.checkbox-label strong, .checkbox-label small { display: block; }
.checkbox-label small { margin-top: 2px; color: var(--muted); font-weight: 400; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; min-height: 54px; margin-top: 30px; padding: 0 22px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 800; }
.primary-button { min-width: 240px; color: white; background: var(--forest); }
.primary-button:hover { background: #0f3021; }
.primary-button:disabled { cursor: wait; opacity: .6; }
.secondary-button { color: var(--forest); background: var(--sage); }
.compact { min-width: auto; }
.form-note { display: inline-block; max-width: 480px; margin: 30px 0 0 18px; color: var(--muted); font-size: 12px; vertical-align: middle; }
.message { margin-top: 24px; padding: 14px 16px; border-radius: 10px; }
.error { color: #722b22; background: #f7e2dd; border: 1px solid #e6bbb2; }

.loading { display: flex; align-items: center; gap: 22px; margin: 28px 0; padding: 28px 32px; border-radius: 18px; color: white; background: var(--forest); }
.loading p { margin: 4px 0 0; color: #cce0d2; }
.loader { flex: 0 0 auto; width: 32px; height: 32px; border: 3px solid rgba(255,255,255,.25); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { margin-top: 32px; }
.history-panel { margin-top:32px; padding:28px 34px; border:1px solid var(--line); border-radius:20px; background:var(--paper); }
.history-panel h2 { margin:0; font-size:30px; }
.history-note,#history-message { color:var(--muted); font-size:13px; }
.history-row { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:16px 0; border-top:1px solid var(--line); }
.history-row strong,.history-row small { display:block; }
.history-row small { margin-top:4px; color:var(--muted); }
.history-row .secondary-button { min-height:40px; margin:0; padding:0 14px; }
.history-buttons { display:flex; gap:8px; }
@media(max-width:560px) { .history-panel { padding:22px 20px; } .history-row { align-items:start; flex-direction:column; } }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.result-actions button { margin-top: 0; }
.result > .message { margin: 20px 34px 0; }
#report-frame { display: block; width: 100%; min-height: 980px; border: 0; background: var(--cream); }
.site-footer { width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 48px; border-top: 1px solid var(--line); color: var(--muted); }
.site-footer span { color: var(--forest); font: 700 18px Georgia, serif; }
.site-footer p { max-width: 700px; margin: 8px 0 0; font-size: 13px; }

[hidden] { display: none !important; }
@media (max-width: 820px) {
  .intro { padding-top: 54px; }
  .form-heading, .result-heading { align-items: flex-start; flex-direction: column; }
  .form-heading p:last-child { text-align: left; }
  legend { float: none; width: auto; padding: 0 0 16px; }
  .form-grid, .address-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-left: 0; }
  .wide { grid-column: span 1; }
}
@media (max-width: 560px) {
  .topbar, main, .site-footer { width: min(100% - 24px, 1100px); }
  .docs-link { font-size: 13px; }
  .brand small { display: none; }
  .intro { padding: 42px 2px; }
  h1 { font-size: 44px; }
  .trust-row { display: grid; gap: 8px; }
  .form-heading, form, .result-heading { padding-left: 20px; padding-right: 20px; }
  .form-grid, .address-grid { grid-template-columns: 1fr; }
  .form-note { display: block; margin: 14px 0 0; }
  .primary-button { width: 100%; }
  .result-actions { width: 100%; flex-direction: column; }
  .result-actions button { width: 100%; }
  #report-frame { min-height: 1180px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .loader { animation: none; } }
