/* —— Base —— */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --border: #e5e5e5;
  --border-strong: #d0d0d0;
  --focus: #1a1a1a;
  --error: #b00020;
  --space: 1.25rem;
  --radius: 4px;
  --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --max: 720px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3.5rem;
}

/* —— Brand header —— */
.print-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.print-brand-logo {
  display: block;
  max-height: 44px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.print-brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.print-brand-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}

.print-report-title {
  display: none;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}

/* —— Form —— */
.group {
  margin: 0 0 2rem;
  padding: 0;
  border: none;
}

.group legend {
  display: block;
  width: 100%;
  margin: 0 0 1rem;
  padding: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
}

@media (min-width: 560px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-grid-single {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  appearance: textfield;
  -moz-appearance: textfield;
}

.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field input::placeholder {
  color: #a3a3a3;
}

.field input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.form-error {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--error);
  border: 1px solid #f0c0c8;
  background: #fff8f9;
  border-radius: var(--radius);
}

/* —— Buttons —— */
.actions {
  margin-top: 0.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.35rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  width: 100%;
  color: #fff;
  background: var(--text);
  border-color: var(--text);
}

.btn-primary:hover {
  background: #333;
  border-color: #333;
}

.btn-primary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-secondary {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: #f7f7f7;
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.results-actions .btn {
  flex: 1 1 auto;
  min-width: 10rem;
}

.results-actions-bottom {
  margin-top: 2.5rem;
  margin-bottom: 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* —— Results —— */
.results-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.results-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.results-date {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.assumptions-block {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.assumptions-block h3 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.assumptions-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.assumptions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.4;
}

.assumptions-table th,
.assumptions-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--border);
}

.assumptions-table th {
  font-weight: 600;
  color: var(--muted);
  background: #fafafa;
  white-space: nowrap;
}

.assumptions-table td:nth-child(1) {
  font-weight: 500;
  white-space: nowrap;
}

.assumptions-table td:nth-child(2) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}

.assumptions-table td:nth-child(3) {
  color: var(--muted);
}

.methodology-note {
  margin: 0.85rem 0 0;
  padding: 0;
  font-size: 0.8rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.45;
  color: var(--muted);
}

.narrative-block {
  margin-bottom: 2.25rem;
}

.narrative-block h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.narrative {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.narrative li {
  margin-bottom: 0.85rem;
  padding-left: 0.25rem;
}

.narrative li:last-child {
  margin-bottom: 0;
}

.calc-formula {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.block-total {
  margin: 0 0 0.65rem;
  padding: 0.85rem 1rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafafa;
}

.block-annual {
  margin: 0;
  padding: 1rem 1.1rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #f5f5f5;
}

/* —— Views —— */
.view[hidden] {
  display: none !important;
}

/* —— Print —— */
@media print {
  @page {
    size: letter;
    margin: 0.5in;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.45;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-brand {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    max-width: none;
    position: static;
    margin: 0 0 0.85rem;
    padding: 0 0 0.65rem;
    border-bottom: 1px solid #ccc;
    background: #fff !important;
    box-shadow: none !important;
  }

  .print-brand-logo {
    display: block;
    max-height: 44px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
  }

  .print-brand-name {
    margin: 0;
    font-size: 14pt;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #000 !important;
    line-height: 1.2;
  }

  .print-report-title {
    display: block !important;
    margin: 0;
    font-size: 10pt;
    font-weight: 500;
    color: #333 !important;
    line-height: 1.3;
  }

  .page {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .no-print,
  .results-actions,
  #view-form {
    display: none !important;
  }

  #view-results {
    display: block !important;
  }

  .results-header {
    border-bottom: 1px solid #ccc;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
  }

  .results-header h2 {
    display: none;
  }

  .results-header h2,
  .assumptions-block h3,
  .narrative-block h3,
  .block-total,
  .block-annual,
  .narrative li {
    color: #000 !important;
  }

  .calc-formula,
  .results-date {
    color: #333 !important;
  }

  .assumptions-block {
    margin-top: 1rem;
    margin-bottom: 0;
    padding-top: 0.65rem;
    border-top: 1px solid #ccc;
  }

  .assumptions-wrap {
    overflow: visible;
  }

  .assumptions-table {
    font-size: 8.5pt;
    width: 100%;
  }

  .assumptions-table th,
  .assumptions-table td {
    border: 1px solid #ccc !important;
    background: #fff !important;
    color: #000 !important;
    padding: 0.28rem 0.4rem;
  }

  .assumptions-table th {
    font-weight: 600;
  }

  .assumptions-table td:nth-child(3) {
    color: #333 !important;
  }

  .methodology-note {
    margin: 0.45rem 0 0;
    font-size: 7.5pt;
    font-style: italic;
    line-height: 1.35;
    color: #555 !important;
    orphans: 3;
    widows: 3;
  }

  .block-total,
  .block-annual {
    background: #fff !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding-left: 0;
    padding-right: 0;
  }

  .block-annual {
    margin-top: 0.35rem;
    padding-top: 0.5rem;
    border-top: 1px solid #ccc !important;
    font-size: 13pt;
  }

  .narrative-block {
    margin-bottom: 1.1rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .btn {
    display: none !important;
  }
}
