:root {
  --navy: #172033;
  --navy-soft: #26324a;
  --teal: #0f766e;
  --teal-soft: #e1f3f0;
  --orange: #df6a2e;
  --paper: #ffffff;
  --surface: #eef2f6;
  --ink: #1b2436;
  --muted: #677287;
  --line: #d8dfe8;
  --success: #167b51;
  --danger: #b4233c;
  font-family: var(--core-font);
  color: var(--ink);
}

/* The shared reset keeps form and report geometry predictable across browsers. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: transparent; }
button, input, select { font: inherit; }
a { color: inherit; }

/* The desktop application frame leaves the A4 report visible while inputs scroll independently. */
.app-bar { height: 68px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.app-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-weight: 800; }
.app-brand b { color: var(--teal); }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--navy); color: #fff; }
.app-bar nav { display: flex; gap: 8px; }
.app-bar nav a { padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 700; }
.app-bar nav a:hover { background: var(--teal-soft); color: var(--teal); }
.app-shell { min-height: calc(100vh - 68px); display: grid; grid-template-columns: minmax(360px, 430px) minmax(720px, 1fr); }

/* Input controls use restrained cards so the application stays clear even on long design sheets. */
.control-panel { height: calc(100vh - 68px); overflow: auto; padding: 30px 26px 110px; background: #fff; border-right: 1px solid var(--line); position: sticky; top: 68px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 750; display: inline-flex; align-items: center; gap: 8px; }
.discipline-tag { display: block; margin-top: 24px; color: var(--teal); letter-spacing: .15em; font-size: 10px; font-weight: 900; }
.control-heading h1 { margin: 9px 0 10px; color: var(--navy); font-size: 32px; line-height: 1.03; letter-spacing: -.035em; }
.control-heading p { margin: 0 0 25px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.project-card, .input-card { margin: 0 0 13px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.input-card { padding-top: 0; }
.input-card summary { margin: 0 -18px; padding: 17px 18px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; color: var(--navy); font-size: 14px; font-weight: 850; }
.input-card summary::-webkit-details-marker { display: none; }
.input-card summary::after { content: "+"; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--teal); font-size: 17px; }
.input-card[open] summary::after { content: "−"; }
.input-card[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.project-card h2 { margin: 0 0 14px; font-size: 14px; color: var(--navy); }
label { display: grid; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 11px; font-weight: 750; }
input, select { width: 100%; min-width: 0; padding: 10px 11px; border: 1px solid #cbd4df; border-radius: 8px; background: #fbfcfd; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#reportNumber::-webkit-inner-spin-button,
#reportNumber::-webkit-outer-spin-button { opacity: 1; height: 22px; margin: 0; }
.field-pair label:last-child, .project-card label:last-child, .input-grid label:last-child { margin-bottom: 0; }
.input-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.field-unit { position: relative; }
.field-unit input { padding-right: 46px; }
.field-unit span { position: absolute; right: 10px; bottom: 11px; color: #8b94a4; font-size: 10px; font-weight: 800; pointer-events: none; }
.action-dock { position: fixed; left: 0; bottom: 0; width: 430px; padding: 14px 26px 18px; display: grid; grid-template-columns: 1fr 1.25fr; gap: 9px; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -9px 25px rgba(20,31,50,.06); z-index: 10; }
.action-dock p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 10px; }
.action-dock button { border: 0; border-radius: 9px; padding: 12px; cursor: pointer; font-weight: 850; }
.primary-button { color: #fff; background: var(--teal); }
.secondary-button { color: var(--navy); background: var(--surface); }

/* The preview displays an exact 210 x 297 mm report, scaled only on narrow screens. */
.preview-stage { padding: 28px 32px 60px; overflow: auto; background: transparent; }
.preview-toolbar { width: 210mm; max-width: 100%; margin: 0 auto 12px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.report-state { color: var(--success); font-weight: 850; }
.report-page { --surface: #eef2f6; --teal-soft: #e1f3f0; width: 210mm; min-height: 297mm; margin: auto; padding: 14mm 15mm 12mm; display: flex; flex-direction: column; background: var(--paper); color: #172033; box-shadow: 0 20px 55px rgba(28,39,61,.16); }
.report-header { min-height: 28mm; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; column-gap: 3mm; border-bottom: 2px solid var(--navy); padding-bottom: 3mm; }
.report-heading { min-width: 0; text-align: left; }
.report-kicker { color: var(--teal); letter-spacing: .14em; font-size: 7.5pt; font-weight: 900; }
.report-header h2 { margin: 2.2mm 0 1mm; color: var(--navy); font-size: 18pt; line-height: 1.05; letter-spacing: -.035em; }
.report-number-mark {
  min-width: 8.5mm; height: 8.5mm; padding: 0 2mm; box-sizing: border-box;
  display: grid; place-items: center; border: 0.4mm solid var(--navy); color: var(--navy);
  font-size: 12pt; font-weight: 800; line-height: 1; background: #fff;
}
.report-header p { margin: 0; color: var(--muted); font-size: 8.5pt; text-align: left; }
.report-logo { width: 46mm; height: 12mm; justify-self: end; align-self: start; display: grid; place-items: center; background: transparent; }
.report-number-mark[hidden] + .report-logo { grid-column: 3; }
.report-logo img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: right center; }
.report-meta { margin: 5mm 0; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; border: 1px solid var(--line); }
.report-meta div { min-height: 15mm; padding: 3mm; border-right: 1px solid var(--line); }
.report-meta div:last-child { border-right: 0; }
.report-meta span, .report-summary span { display: block; margin-bottom: 1.2mm; color: var(--muted); font-size: 6.5pt; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.report-meta strong { display: block; font-size: 8pt; word-break: break-word; }
.report-summary { min-height: 16mm; padding: 3.5mm 4mm; display: grid; grid-template-columns: 38mm 1fr; align-items: center; gap: 5mm; color: #fff; background: var(--navy); }
.report-summary span { color: #9eb5ba; }
.report-summary p { margin: 0; color: #d6dce6; font-size: 7.5pt; line-height: 1.45; }
.status-pill { display: inline-flex; width: fit-content; padding: 1.3mm 2.4mm; border-radius: 10mm; background: #dff5ea; color: var(--success); font-size: 8pt; }
.status-pill.fail { background: #fde7eb; color: var(--danger); }
.status-pill.info { background: #e1effb; color: #195a91; }
.report-section { margin-top: 5mm; }
.section-title { display: flex; align-items: center; gap: 2.5mm; margin-bottom: 2.5mm; }
.section-title span { width: 6mm; height: 6mm; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); font-size: 6pt; font-weight: 900; }
.section-title h3 { margin: 0; font-size: 9pt; text-transform: uppercase; letter-spacing: .08em; }
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.report-cell { min-height: 13mm; padding: 2.3mm 2.7mm; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.report-cell span, .result-row span { display: block; color: var(--muted); font-size: 6.5pt; }
.report-cell strong { display: block; margin-top: 1.2mm; font-size: 8.5pt; }
.result-highlights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2mm; margin-bottom: 2.5mm; }
.result-highlights[data-count="1"] { grid-template-columns: 1fr; }
.result-highlight { padding: 3mm; background: var(--teal-soft); border-left: 1.3mm solid var(--teal); }
.result-highlight span { display: block; color: #47716d; font-size: 6pt; text-transform: uppercase; letter-spacing: .07em; }
.result-highlight strong { display: block; margin-top: 1.2mm; color: var(--navy); font-size: 12pt; }
.result-table { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.result-row { min-height: 11mm; padding: 2.2mm 2.7mm; display: flex; justify-content: space-between; align-items: center; gap: 4mm; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-row strong { font-size: 8pt; text-align: right; }
.calculation-steps { margin-bottom: 2.5mm; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.calculation-step { min-height: 9mm; padding: 1.8mm 2.2mm; display: grid; grid-template-columns: 28mm minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; gap: 3mm; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calculation-step span { color: var(--muted); font-size: 6.3pt; font-weight: 750; }
.calculation-step strong { color: var(--navy); font-size: 7.2pt; line-height: 1.35; }
.calculation-step small { color: #4f5a6d; font-size: 6.1pt; line-height: 1.35; }
.calculation-step-heading { min-height: 7mm; background: var(--surface); }
.calculation-step-heading b { color: var(--navy); font-size: 6.2pt; text-transform: uppercase; letter-spacing: .06em; }
.method-notes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2mm 5mm; }
.method-note { position: relative; margin: 0; padding-left: 4mm; color: #4f5a6d; font-size: 6.7pt; line-height: 1.45; }
.method-note::before { content: ""; position: absolute; left: 0; top: 2mm; width: 1.5mm; height: 1.5mm; border-radius: 50%; background: var(--orange); }
.report-footer { margin-top: auto; padding-top: 3mm; border-top: 1px solid var(--navy); color: var(--muted); font-size: 6pt; }
.report-footer p { margin: 0 0 2mm; line-height: 1.4; }
.report-footer div { display: flex; justify-content: space-between; color: var(--navy); font-weight: 800; }

/* Long calculations retain all review information without growing beyond A4. */
.report-page.compact-report .report-section { margin-top: 4mm; }
.report-page.compact-report .section-title { margin-bottom: 2mm; }
.report-page.compact-report .result-row { min-height: 10.5mm; padding-top: 1.9mm; padding-bottom: 1.9mm; }
.report-page.compact-report .method-note { font-size: 6.4pt; line-height: 1.35; }

/* WIND-05 uses a compact traceable schedule so every step and code reference fits one A4 page. */
.report-page.wind05-report { padding-top: 11mm; padding-bottom: 9mm; }
.wind05-report .report-header { min-height: 25mm; }
.wind05-report .report-section { margin-top: 3.5mm; }
.wind05-report .section-title { margin-bottom: 1.8mm; }
.wind05-report .report-cell { min-height: 11mm; padding-top: 1.8mm; padding-bottom: 1.8mm; }
.wind05-report .result-highlight { padding: 2.5mm 3mm; }
.wind05-report .result-highlight strong { font-size: 13pt; }
.wind05-report .calculation-step { min-height: 8.2mm; padding-top: 1.35mm; padding-bottom: 1.35mm; }
.wind05-report .method-notes { gap: 1.5mm 4mm; }
.wind05-report .method-note { font-size: 6.1pt; line-height: 1.32; }
.wind05-report .report-footer { padding-top: 2mm; }

/* Responsive rules keep calculations usable when the viewport cannot show A4 at full size. */
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: minmax(340px, 390px) minmax(600px, 1fr); }
  .action-dock { width: 390px; }
  .preview-stage { padding-left: 20px; padding-right: 20px; }
  .report-page, .preview-toolbar { transform-origin: top center; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .control-panel { position: static; width: 100%; height: auto; overflow: visible; padding-bottom: 28px; }
  .action-dock { position: sticky; width: auto; margin: 20px -26px -28px; bottom: 0; }
  .preview-stage { padding: 25px 12px 50px; }
  .report-page { width: 100%; min-height: auto; aspect-ratio: 210 / 297; padding: 5vw; }
  .preview-toolbar { width: 100%; }
}
@media (max-width: 560px) {
  .app-bar { padding: 0 16px; }
  .app-bar nav a:first-child { display: none; }
  .control-panel { padding-left: 17px; padding-right: 17px; }
  .field-pair, .input-grid { grid-template-columns: 1fr; }
  .action-dock { margin-left: -17px; margin-right: -17px; padding-left: 17px; padding-right: 17px; }
  .preview-stage { display: none; }
}

/* Print rules remove the application chrome and send only the exact A4 report to the printer. */
@page { size: A4 portrait; margin: 0; }
@media print {
  :root, body { background: #fff !important; }
  .no-print { display: none !important; }
  .app-shell, .preview-stage { display: block; min-height: 0; padding: 0; overflow: visible; }
  .report-page { width: 210mm; height: 297mm; min-height: 297mm; margin: 0; padding: 14mm 15mm 12mm; box-shadow: none; break-after: page; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .report-page.wind05-report { padding-top: 11mm; padding-bottom: 9mm; }
}
