:root {
  --paper: #f6f7f4;
  --surface: #ffffff;
  --surface-alt: #eef4f1;
  --ink: #202424;
  --muted: #5d6661;
  --border: #d8ddd7;
  --accent: #1f6f5b;
  --accent-dark: #174f42;
  --accent-soft: #dceee7;
  --warning: #a86716;
  --risk: #8e2f4a;
  --focus: #2d6cdf;
  --shadow: 0 18px 55px rgba(35, 45, 40, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(31, 111, 91, 0.08), rgba(255, 255, 255, 0) 280px),
    var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-action {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(45, 108, 223, 0.35);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--border);
  background: rgba(246, 247, 244, 0.95);
  backdrop-filter: blur(14px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-dark);
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.15rem, 2vw, 1.8rem);
}

h2 {
  font-size: 1.22rem;
}

h3 {
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.text-action {
  width: auto;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.icon-button.danger:hover {
  border-color: var(--risk);
  color: var(--risk);
}

.file-action input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.logo-uploader {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}

.logo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.logo-upload-button {
  display: inline-flex;
  align-items: center;
  margin-top: 0;
}

.logo-preview {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
}

.logo-preview img {
  display: block;
  width: 92px;
  max-height: 72px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 8px;
}

.logo-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(420px, 1fr) minmax(360px, 0.85fr);
  gap: 18px;
  padding: 20px clamp(16px, 3vw, 34px) 34px;
}

.sidebar,
.workspace,
.report-pane {
  min-width: 0;
}

.privacy-panel,
.source-panel,
.workspace,
.report-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.privacy-panel {
  padding: 16px;
}

.text-button {
  min-height: 38px;
  margin-top: 12px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.text-button:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.privacy-title,
.source-title,
.progress-label {
  margin: 0 0 6px;
  font-weight: 800;
}

.privacy-panel p,
.source-panel p,
.progress-meta,
#reportStatus {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.progress-block {
  display: block;
  margin: 16px 0;
  padding: 14px 0 4px;
}

.progress-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.progress-value {
  margin: 0;
  font-weight: 800;
  color: var(--accent-dark);
}

.progress-bar {
  width: 100%;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: #dfe4dd;
  color: var(--accent);
}

.progress-bar::-webkit-progress-bar {
  background: #dfe4dd;
  border-radius: 999px;
}

.progress-bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.progress-bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.93rem;
  font-weight: 700;
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.step-button {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}

.step-button:hover,
.step-button.active {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.step-button.skipped {
  opacity: 0.64;
}

.step-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.step-name {
  display: block;
  font-weight: 800;
}

.step-state {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.source-panel {
  display: grid;
  gap: 7px;
  padding: 16px;
}

.source-panel a {
  color: var(--accent-dark);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.workspace,
.report-pane {
  overflow: hidden;
}

.workspace-header,
.report-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #fbfcfb);
}

.branch-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 360px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.yes {
  border-color: rgba(31, 111, 91, 0.35);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pill.warn {
  border-color: rgba(168, 103, 22, 0.35);
  background: #fff4df;
  color: #744a0c;
}

.pill.risk {
  border-color: rgba(142, 47, 74, 0.35);
  background: #fae8ee;
  color: var(--risk);
}

#questionnaireForm {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.section-note {
  margin: 0;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--muted);
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  align-content: start;
}

.field.full {
  grid-column: 1 / -1;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field label,
.legend-label {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.required-star {
  color: var(--risk);
}

.hint {
  position: relative;
}

.hint summary {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  list-style: none;
  cursor: help;
}

.hint summary::-webkit-details-marker {
  display: none;
}

.hint p {
  position: absolute;
  right: 0;
  z-index: 3;
  width: min(310px, 80vw);
  margin: 7px 0 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--ink);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: var(--shadow);
}

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

input[type="text"],
input[type="date"],
input[type="number"],
select {
  padding: 0 12px;
}

textarea {
  min-height: 104px;
  padding: 12px;
  resize: vertical;
}

.choice-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.choice-group.stacked {
  grid-template-columns: 1fr;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
}

.choice input {
  flex: 0 0 auto;
  margin-top: 1px;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.help-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.form-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px 18px;
}

.form-nav button {
  min-width: 112px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.form-nav button:last-child {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.form-nav button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  background: #eef0ec;
  color: var(--muted);
  border-color: var(--border);
}

.report-pane {
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.report {
  padding: 22px;
  background: #ffffff;
}

.report-cover {
  min-height: 340px;
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(31, 111, 91, 0.12), rgba(168, 103, 22, 0.08)),
    #ffffff;
}

.report-logo {
  display: block;
  max-width: 190px;
  max-height: 95px;
  object-fit: contain;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px;
}

.report h2,
.report h3 {
  margin: 24px 0 10px;
}

.report p {
  line-height: 1.45;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 18px;
  font-size: 0.88rem;
}

.report-table th,
.report-table td {
  vertical-align: top;
  padding: 8px 9px;
  border: 1px solid #dfe3de;
  text-align: left;
}

.report-table th {
  width: 34%;
  background: #f3f5f1;
  font-weight: 800;
}

.report-footer {
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.report-page-disclaimer {
  display: none;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  align-items: end;
  margin-top: 34px;
}

.signature-block {
  break-inside: avoid;
}

.signature-item {
  display: grid;
  grid-template-rows: 48px auto;
  gap: 7px;
  min-width: 0;
  break-inside: avoid;
}

.signature-rule {
  align-self: end;
  height: 1px;
  border-bottom: 1px solid var(--ink);
}

.signature-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.25;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 23, 0.52);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: min(720px, 92vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #fbfcfb);
}

.assurance-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 20px 36px 24px;
  color: var(--ink);
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }

  .report-pane {
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 780px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace-header,
  .report-toolbar {
    flex-direction: column;
  }

  .branch-summary {
    justify-content: flex-start;
  }

  .field-grid,
  .choice-group,
  .logo-preview,
  .signature-grid {
    grid-template-columns: 1fr;
  }

  .icon-button {
    min-width: 0;
  }

  .modal {
    align-items: start;
  }
}

@media print {
  @page {
    margin: 0.55in;
  }

  body {
    background: #ffffff;
  }

  .app-header,
  .sidebar,
  .workspace,
  .report-toolbar,
  .modal,
  .toast {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .report-pane {
    display: block;
    max-height: none;
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  .report {
    padding: 0;
  }

  .report-page-disclaimer {
    display: block;
    position: static;
    margin: 14px auto 0;
    padding: 8px 0 0;
    border-top: 1px solid #d8ddd7;
    color: #5d6661;
    font-size: 9px;
    line-height: 1.25;
    text-align: center;
    max-width: 7.2in;
  }

  .report-cover {
    min-height: 8.2in;
    page-break-after: always;
    border: 0;
  }

  .signature-block {
    break-before: page;
    page-break-before: always;
    break-inside: avoid;
  }

  .report-table th,
  .report-table td {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
