:root {
  color-scheme: light;
  --navy: #14213d;
  --navy-dark: #0c1528;
  --paper: #f6f3ee;
  --white: #ffffff;
  --ink: #1b1f27;
  --muted: #555b66;
  --line: #d9d4cb;
  --accent: #c8642a;
  --increase-bg: #fbe8dc;
  --increase-ink: #7a3410;
  --decrease-bg: #e2f0e6;
  --decrease-ink: #1c5433;
  --review-bg: #f8e0df;
  --review-ink: #86201c;
  --info-bg: #e3e9f4;
  --info-ink: #1f3b6e;
  --neutral-bg: #ece9e3;
  --neutral-ink: #4a4f59;
  --radius: 6px;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--navy);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--navy-dark);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  color: var(--navy);
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  margin: 0.4rem 0 1rem;
  max-width: 22ch;
}

h2 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.wrap {
  width: min(1180px, 100% - 2rem);
  margin-inline: auto;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--white);
  padding: 0.5rem 1rem;
  z-index: 10;
}

.skip:focus {
  left: 1rem;
}

/* Header and footer */

.site-header {
  background: var(--navy);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.9rem 0;
}

.brand {
  color: var(--white);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.2rem;
  text-decoration: none;
}

.brand:hover {
  color: var(--white);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.site-header .nav a {
  color: #dfe5f0;
  text-decoration: none;
}

.site-header .nav a:hover,
.site-header .nav a[aria-current="page"] {
  color: var(--white);
  text-decoration: underline;
}

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  color: var(--muted);
  font-size: 0.93rem;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding: 1.5rem 0 2rem;
}

.footer-row p {
  margin: 0;
  max-width: 60ch;
}

/* Intro */

.intro {
  padding: 2.5rem 0 1.5rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  font-size: 1.1rem;
  max-width: 62ch;
  margin: 0 0 1.5rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

/* Buttons */

.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius);
  border: 2px solid var(--navy);
  background: var(--navy);
  color: var(--white);
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--navy-dark);
  border-color: var(--navy-dark);
  color: var(--white);
}

.button.secondary {
  background: transparent;
  color: var(--navy);
}

.button.secondary:hover {
  background: #e7e2d9;
  color: var(--navy-dark);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.link-button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-button:disabled {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
}

/* Tool */

.tool {
  padding: 1rem 0 2rem;
}

.tool > .wrap > h2 {
  margin-top: 0.5rem;
}

.step {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1rem 0;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 0.95rem;
  flex: none;
}

.hint {
  color: var(--muted);
  font-size: 0.93rem;
  margin: 0.4rem 0;
}

.file-grid,
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
}

.file-card {
  border: 1px dashed #b9b2a6;
  border-radius: var(--radius);
  padding: 1rem;
  background: #fbfaf7;
}

.file-label {
  font-weight: 700;
  color: var(--navy);
}

.file-card input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  font: inherit;
}

.file-status {
  margin: 0.5rem 0 0;
  font-size: 0.93rem;
  overflow-wrap: anywhere;
}

.map-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0;
  min-width: 0;
}

.map-card legend {
  font-weight: 700;
  color: var(--navy);
  padding: 0 0.3rem;
}

.map-card.is-empty .field,
.map-card.is-empty .field-row,
.map-card.is-empty .preview {
  opacity: 0.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.6rem 0;
  min-width: 0;
}

.field-row {
  display: flex;
  gap: 0.75rem;
}

.field-row .field {
  flex: 1;
}

.field-row .field-small {
  flex: 0 0 7rem;
}

.field label {
  font-size: 0.93rem;
  font-weight: 600;
}

.req {
  font-weight: 400;
  color: var(--muted);
}

select,
input[type="text"],
input[type="number"] {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #b9b2a6;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  min-width: 0;
}

select:disabled,
input:disabled {
  background: #f1eee8;
}

.options {
  margin: 1rem 0;
  display: grid;
  gap: 0.6rem;
}

.option-group {
  border: 0;
  padding: 0;
  margin: 0;
}

.option-group legend {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 1.25rem;
}

.choice input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--navy);
}

.field-supplier {
  max-width: 26rem;
}

.preview {
  margin-top: 0.75rem;
}

.preview summary {
  cursor: pointer;
  color: var(--navy);
  font-weight: 600;
}

.notice {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.notice-error {
  background: var(--review-bg);
  color: var(--review-ink);
  border: 1px solid #e7b6b3;
}

/* Tables */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  margin-top: 0.5rem;
}

.preview-table,
.results-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid #ece8e1;
  padding: 0.3rem 0.5rem;
  text-align: left;
  white-space: nowrap;
}

.preview-table th {
  color: var(--muted);
  font-weight: 400;
  background: #f7f5f1;
}

.preview-table tr.is-header td {
  font-weight: 700;
  background: #efeae1;
}

.results-table th,
.results-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #ece8e1;
  text-align: left;
  vertical-align: top;
}

.results-table thead th {
  position: sticky;
  top: 0;
  background: #f1ede6;
  color: var(--navy);
  white-space: nowrap;
  font-weight: 700;
}

.results-table tbody tr:nth-child(even) {
  background: #fbfaf7;
}

.results-table td:nth-child(2) {
  white-space: nowrap;
}

.results-table td:last-child {
  min-width: 18rem;
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag-increase {
  background: var(--increase-bg);
  color: var(--increase-ink);
}

.tag-decrease {
  background: var(--decrease-bg);
  color: var(--decrease-ink);
}

.tag-review {
  background: var(--review-bg);
  color: var(--review-ink);
}

.tag-info {
  background: var(--info-bg);
  color: var(--info-ink);
}

.tag-neutral {
  background: var(--neutral-bg);
  color: var(--neutral-ink);
}

/* Results summary */

.summary-lead {
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
}

.summary-detail {
  color: var(--muted);
  margin: 0.75rem 0 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 0.6rem;
  margin: 0;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  border-left-width: 5px;
}

.stat dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.stat dd {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.stat-increase {
  border-left-color: #d9884f;
}

.stat-decrease {
  border-left-color: #4f9a6c;
}

.stat-review {
  border-left-color: #c0504a;
}

.stat-new,
.stat-old {
  border-left-color: #5c7bb5;
}

.stat-unchanged {
  border-left-color: #a8a295;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0.25rem;
}

.filter {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #b9b2a6;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.filter:hover {
  border-color: var(--navy);
}

.filter[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

/* Facts and prose */

.facts {
  padding: 1rem 0;
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 1rem 3rem;
}

.facts p {
  max-width: 62ch;
}

.plain-list {
  padding-left: 1.2rem;
}

.plain-list li {
  margin: 0.35rem 0;
}

.page {
  padding: 2rem 0;
}

.prose {
  max-width: 760px;
}

.prose p,
.prose li,
.prose dd {
  max-width: 68ch;
}

.definitions dt {
  font-weight: 700;
  color: var(--navy);
  margin-top: 0.9rem;
}

.definitions dd {
  margin: 0.2rem 0 0;
}

@media (max-width: 520px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .field-row .field-small {
    flex: 1;
  }

  .step {
    padding: 1rem;
  }
}

@media print {
  .site-header,
  .site-footer,
  .intro,
  .facts,
  #step-files,
  #step-columns,
  .filters,
  .actions {
    display: none !important;
  }

  body {
    background: var(--white);
  }
}

/* Margin calculator */

.calc-form {
  margin-top: 1.5rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 0.5rem 1rem;
}

.field-error {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--review-ink);
}

input[aria-invalid="true"] {
  border-color: #c0504a;
}

.result-list {
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.result-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #ece8e1;
}

.result-list dt {
  color: var(--muted);
}

.result-list dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result-list .result-key dt,
.result-list .result-key dd {
  color: var(--navy);
  font-weight: 700;
}

@media (max-width: 520px) {
  .result-list > div {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
}

/* Guides */

.meta {
  color: var(--muted);
  font-size: 0.93rem;
  margin: 0 0 1.5rem;
}

.guide-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.guide-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.guide-list a {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
}

.guide-list p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.prose pre {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.92rem;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.prose ol {
  padding-left: 1.3rem;
}

.prose ol li {
  margin: 0.4rem 0;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
  margin: 1rem 0;
  display: block;
  overflow-x: auto;
}

.data-table th,
.data-table td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  text-align: right;
  white-space: nowrap;
}

.data-table th {
  background: #f1ede6;
  color: var(--navy);
}
