:root {
  --paper: #f3efe6;
  --sheet: #fffdf6;
  --ink: #1c1914;
  --muted: #6b6458;
  --rule: #cfc6b6;
  --scoria: #9b2c1a;
  --karaka: #3d5c3a;
  --amber: #d4a017;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 11px,
      rgba(28, 25, 20, 0.03) 11px,
      rgba(28, 25, 20, 0.03) 12px
    ),
    var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
}

header {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 90%, white);
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.25rem;
}

.brand span {
  margin-left: 0.4rem;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
}

nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--ink); }

main { padding: 2rem 1rem 4rem; }

.kicker {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  max-width: 40rem;
  margin: 0.4rem 0 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  font-weight: 500;
}

h2 { font-size: 1.8rem; font-weight: 500; }

.lede {
  max-width: 36rem;
  margin: 0.75rem 0 0;
  font-size: 1.15rem;
  color: var(--muted);
}

.workbench {
  display: grid;
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (min-width: 960px) {
  .workbench { grid-template-columns: minmax(0, 1fr) 22rem; }
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

input, select, button {
  font: 500 14px ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

input, select {
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
}

button {
  height: 2.5rem;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}

button.outline, button.ghost {
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--rule);
}

button.ghost { border-color: transparent; }

.inputs {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.inputs > p { margin: 0; }

.actions, .row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.actions label {
  flex: 1;
  min-width: 12rem;
}

.row-between { justify-content: space-between; }

.grid-2, .grid-3 {
  display: grid;
  align-items: stretch;
  gap: 0.75rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }

.grid-2 label,
.grid-3 label {
  min-height: 100%;
}

.grid-2 label :is(input, select),
.grid-3 label :is(input, select) {
  margin-top: auto;
}

#sections {
  display: grid;
  gap: 1rem;
}

.section, .pricebook {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--sheet);
}

fieldset.section { min-width: 0; }

.muted, .note { color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; }
.note { display: block; font-size: 12px; }

.banner {
  padding: 0.75rem 1rem;
  border: 1px solid var(--scoria);
  background: #f8e6e1;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

aside { position: sticky; top: 1rem; align-self: start; }

.sheet {
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--sheet);
  box-shadow: 4px 6px 0 rgba(28, 25, 20, 0.06);
}

.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.diagram { width: 100%; height: 7rem; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem 0.8rem;
  margin: 0.5rem 0 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

.stats dt { color: var(--muted); }
.stats dd { margin: 0; }
.display { font-family: Georgia, serif; font-size: 1.6rem; }
.span-2 { grid-column: 1 / -1; }

.lines {
  margin: 1rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px dashed var(--rule);
  list-style: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

.lines li, .money p { display: flex; justify-content: space-between; gap: 0.75rem; }
.qty { white-space: nowrap; font-variant-numeric: tabular-nums; }
.money { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--rule); font-family: ui-sans-serif, system-ui, sans-serif; }
.total { font-weight: 700; }

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge.fail { background: var(--scoria); color: white; }
.badge.check { background: var(--amber); color: var(--ink); }
.badge.ok { background: var(--karaka); color: white; }

.warnings { margin-top: 1rem; display: grid; gap: 0.5rem; }
.warn {
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--rule);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}
.warn.fail { border-color: var(--scoria); background: #f8e6e1; }
.warn.check { border-color: var(--amber); background: #f7efd8; }
.warn-title { margin: 0 0 0.35rem; font-weight: 700; }
.warn.fail .warn-title { color: var(--scoria); }
.warn p { margin: 0; }

.copy, .faq, .related { max-width: 40rem; margin-top: 3rem; font-size: 1.05rem; line-height: 1.6; }
.related ul { padding: 0; list-style: none; }
.related li { padding: 0.4rem 0; border-top: 1px solid var(--rule); }
.related li:last-child { border-bottom: 1px solid var(--rule); }
.related a { color: var(--ink); }
.faq details { padding: 1rem 0; border-top: 1px solid var(--rule); }
.faq details:last-child { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; font-size: 1.1rem; }

footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 1rem;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
}

footer a { color: inherit; }

.status {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
}

@media print {
  header, nav, footer, button, .copy, .faq, .related { display: none !important; }
  body { background: white; }
  aside { position: static; }
}
