:root {
  color-scheme: light;
  --paper: #eef2f5;
  --ink: #172d37;
  --muted: #485d67;
  --edge: #c5cfd6;
  --field: #fcfdfe;
  --accent: #1d5269;
  --deep: #123e52;
  --tint: #dceaf0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 system-ui, sans-serif;
}

.wrap {
  width: min(76rem, calc(100% - 2 * clamp(1rem, 4vw, 3rem)));
  margin-inline: auto;
}

.masthead {
  display: flex;
  justify-content: space-between;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--edge);
  gap: 1rem;
  font-size: .875rem;
}

.masthead span { font-weight: 700; }
a { color: var(--deep); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: .13em; }

.intro { padding-block: clamp(1.75rem, 5vw, 4rem) clamp(1.5rem, 3.5vw, 2.75rem); }

h1 {
  margin: 0;
  font: 500 clamp(2.5rem, 7vw, 5rem)/1 Georgia, serif;
  letter-spacing: -.042em;
}

.intro p { margin: .85rem 0 0; max-width: 34rem; color: var(--muted); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .92fr);
  align-items: start;
  gap: clamp(1.5rem, 4vw, 3.5rem);
}

fieldset {
  min-width: 0;
  margin: 0 0 1.35rem;
  padding: .9rem 0 0;
  border: 0;
  border-top: 1px solid var(--edge);
}

legend { padding: 0 .65rem 0 0; font-weight: 700; }
.field-note { margin: 0 0 .65rem; color: var(--muted); font-size: .85rem; }

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem 1rem;
}

label {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: .28rem;
  font-size: .875rem;
  color: var(--muted);
}

input, select, button {
  min-height: 2.75rem;
  font: inherit;
  border: 1px solid var(--edge);
  border-radius: .3rem;
}

input, select {
  width: 100%;
  padding: .53rem .6rem;
  background: var(--field);
  color: var(--ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

input:disabled { background: var(--paper); color: var(--muted); opacity: .68; }

button {
  width: 100%;
  padding: .6rem 1rem;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover { background: var(--deep); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.statement {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid var(--edge);
  border-top: 4px solid var(--accent);
  background: var(--field);
  border-radius: .25rem;
}

.statement h2 { margin: 0 0 .9rem; font: 500 1.55rem/1.1 Georgia, serif; }

.total {
  display: grid;
  gap: .25rem;
  padding: .8rem .9rem;
  background: var(--tint);
  color: var(--deep);
  border-radius: .25rem;
}

.total span { font-size: .875rem; font-weight: 650; }
.total strong { font-size: clamp(1.65rem, 4vw, 2.5rem); line-height: 1.18; overflow-wrap: anywhere; }

dl { margin: .6rem 0 0; }
dl > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: .75rem; }

dl > div, th, td {
  border-bottom: 1px solid var(--edge);
  padding: .45rem 0;
  font-size: .85rem;
}

dt, caption { color: var(--muted); }
dd, td, .total strong { font-variant-numeric: tabular-nums; }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; min-width: 0; }

table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: .9rem; }
caption { text-align: left; font-size: .85rem; font-weight: 700; }
th, td { text-align: right; overflow-wrap: anywhere; }
th:first-child { width: 14%; text-align: left; }
th:not(:first-child), td { padding-left: .25rem; }

#error {
  padding: .7rem .85rem;
  margin: 0;
  border: 1px solid #a03423;
  border-radius: .25rem;
  color: #7a2618;
}

footer {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  margin-top: clamp(2rem, 6vw, 4rem);
  padding-block: 1rem 2rem;
  border-top: 1px solid var(--edge);
  color: var(--muted);
  font-size: .875rem;
}

footer p { margin: 0; }
footer nav { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }

@media (max-width: 57rem) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 23rem) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  dl > div { grid-template-columns: minmax(0, 1fr) minmax(0, 43%); }
}
