:root {
  --desk: #e8ebef;
  --paper: #ffffff;
  --ink: #101114;
  --ink-2: #3a3f48;
  --muted: #5d6470;
  --rule: #d3d8df;
  --rule-2: #eceff3;
  --red: #c8102e;
  --red-ink: #a00d25;
  --focus: #1f5fd1;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --sans: 'Instrument Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  --wrap: 1140px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--desk); color: var(--ink); font: 400 17px/1.6 var(--sans); overflow-x: hidden; }
img, svg { max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: 10px 14px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
h1, h2, h3 { font-family: var(--sans); font-stretch: 82%; line-height: 1.1; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 700; margin: 0 0 14px; }
h2 { font-size: 1.6rem; font-weight: 650; margin: 0 0 14px; }
h3 { font-size: 1.2rem; font-weight: 650; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 62ch; margin: 0; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Header */
.top { background: var(--paper); border-bottom: 1px solid var(--ink); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 1.3rem; font-stretch: 80%; font-weight: 500; letter-spacing: -0.01em; }
.brand b { font-weight: 700; }
.nav { display: flex; gap: 2px; }
.nav a { text-decoration: none; padding: 8px 12px; font-size: .95rem; font-weight: 500; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.nav a[aria-current] { border-bottom-color: var(--red); }

/* Hero / tool layout */
.hero { padding: 48px 0 56px; border-bottom: 1px solid var(--rule); }
.hero-copy { margin-bottom: 30px; }
.hero h1 { max-width: 15ch; }
.tool-page { padding: 28px 24px 48px; }
.tool-head { margin: 10px 0 26px; }
.crumbs { font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 32px; align-items: start; }

/* Form as a worksheet */
.sheet-form { counter-reset: sec; }
.sheet-form fieldset { border: 0; border-top: 1px solid var(--ink); margin: 0 0 22px; padding: 14px 0 0; min-width: 0; }
.sheet-form legend { counter-increment: sec; font-weight: 650; font-size: 1.02rem; padding: 0 10px 0 0; }
.sheet-form legend::before { content: counter(sec, decimal-leading-zero); font: 500 .8rem var(--mono); color: var(--red); margin-right: 10px; }
.field { display: block; margin: 10px 0 16px; }
.f-label { display: block; font-weight: 550; font-size: .95rem; margin-bottom: 4px; }
.f-label small { font-weight: 400; color: var(--muted); font-size: .85rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.money, .unit-wrap { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--ink); background: var(--paper); padding: 0 10px; }
.money:focus-within, .unit-wrap:focus-within { border-bottom-color: var(--focus); }
.money > span, .unit { font: 500 1rem var(--mono); color: var(--muted); }
input, select { font: 500 1.15rem var(--mono); color: var(--ink); width: 100%; min-width: 0; }
.money input, .unit-wrap input { border: 0; background: transparent; padding: 10px 0 8px; }
.money input:focus-visible, .unit-wrap input:focus-visible { outline: none; }
select { font-family: var(--sans); font-size: 1rem; border: 0; border-bottom: 2px solid var(--ink); background: var(--paper); padding: 11px 8px 9px; border-radius: 0; }
.help { font-size: .88rem; color: var(--muted); margin: 6px 0 0; }

/* Invoice */
.slip-col { position: sticky; top: 16px; }
.invoice { background: var(--paper); border: 1px solid var(--rule); padding: 28px 30px 30px; position: relative;
  box-shadow: 0 1px 0 var(--rule), 0 24px 40px -32px rgba(16, 17, 20, .35); }
.invoice::after { content: ''; position: absolute; left: -1px; right: -1px; bottom: -9px; height: 9px;
  background: linear-gradient(-45deg, transparent 6px, var(--paper) 0) 0 0 / 12px 9px repeat-x, linear-gradient(45deg, transparent 6px, var(--paper) 0) 0 0 / 12px 9px repeat-x; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 3px solid var(--ink); padding-bottom: 14px; }
.inv-title { font-size: 1.8rem; font-weight: 700; font-stretch: 78%; margin: 0; line-height: 1; }
.inv-no { font: 500 .8rem var(--mono); color: var(--muted); margin: 6px 0 0; }
.inv-meta { margin: 0; display: grid; gap: 2px; text-align: right; }
.inv-meta div { display: flex; gap: 10px; justify-content: flex-end; }
.inv-meta dt { color: var(--muted); font-size: .82rem; }
.inv-meta dd { margin: 0; font: 500 .85rem var(--mono); }
.inv-table { overflow-x: auto; }
.inv-table table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.inv-table th { font-size: .78rem; font-weight: 600; color: var(--muted); text-align: left; padding: 10px 6px 6px; border-bottom: 1px solid var(--ink); }
.inv-table th.num { text-align: right; }
.inv-table td { padding: 11px 6px; border-bottom: 1px solid var(--rule-2); vertical-align: top; font-size: .95rem; }
.inv-table td:first-child, .inv-table th:first-child { padding-left: 0; }
.inv-table td:last-child, .inv-table th:last-child { padding-right: 0; }
.inv-table td small { display: block; color: var(--muted); font-size: .8rem; }
.inv-table tr.key td { font-weight: 600; }
.inv-table tr.key td:last-child { color: var(--red-ink); }
.inv-total { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 66px 0 6px; border-bottom: 3px double var(--ink); }
.inv-total span:first-child { font-weight: 600; }
.inv-total strong { font: 600 clamp(1.8rem, 4.6vw, 2.6rem) var(--mono); letter-spacing: -0.03em; }
.stamp { position: absolute; right: 8px; top: 8px; transform: rotate(-9deg); color: var(--red); border: 3px solid var(--red); outline: 1.5px solid var(--red); outline-offset: 3px;
  padding: 4px 12px 5px; text-align: center; font-family: var(--mono); line-height: 1.1; opacity: .88; mix-blend-mode: multiply; pointer-events: none; border-radius: 3px; }
.stamp b { display: block; font-size: 1.15rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; }
.stamp i { display: block; font-style: normal; font-size: .78rem; font-weight: 500; }
.stamp.hit { animation: stamp .32s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes stamp { 0% { transform: rotate(-9deg) scale(1.7); opacity: 0; } 100% { transform: rotate(-9deg) scale(1); opacity: .88; } }
.ledger { margin-top: 18px; }
.ledger-title { font-weight: 600; margin: 0 0 6px; font-size: .95rem; }
.ledger dl { margin: 0; }
.ledger div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dotted var(--rule); font-size: .92rem; }
.ledger dt { color: var(--ink-2); }
.ledger dd { margin: 0; font-family: var(--mono); text-align: right; }
.ledger .keep dt, .ledger .keep dd { font-weight: 600; color: var(--ink); }
.inv-note { font-size: .86rem; color: var(--muted); margin: 16px 0 0; }
.inv-empty { margin: 0; color: var(--muted); }

/* Blocks */
.block { padding: 48px 24px 8px; }
.split { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 40px; }
.split > div { min-width: 0; }
.tool-index { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--ink); counter-reset: t; }
.tool-index li { counter-increment: t; border-bottom: 1px solid var(--rule); }
.tool-index a { display: grid; grid-template-columns: 3rem 1fr; grid-template-rows: auto auto; padding: 16px 0; text-decoration: none; column-gap: 8px; }
.tool-index a::before { content: counter(t, decimal-leading-zero); font: 500 .85rem var(--mono); color: var(--red); grid-row: span 2; padding-top: 4px; }
.ti-name { font-weight: 650; font-size: 1.15rem; }
.ti-desc { color: var(--muted); }
.tool-index a:hover .ti-name { text-decoration: underline; text-underline-offset: 4px; }
.table-scroll { overflow-x: auto; }
table.ref { width: 100%; border-collapse: collapse; background: var(--paper); font-size: .95rem; }
table.ref caption { text-align: left; color: var(--muted); font-size: .88rem; padding-bottom: 6px; }
table.ref th, table.ref td { padding: 9px 12px; border-bottom: 1px solid var(--rule); text-align: left; }
table.ref th { border-bottom: 1px solid var(--ink); font-weight: 600; font-size: .88rem; }
table.ref th.num { text-align: right; }
.note { font-size: .9rem; color: var(--muted); }
.post-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--ink); }
.post-list li { border-bottom: 1px solid var(--rule); }
.post-list a { display: grid; gap: 2px; padding: 16px 0; text-decoration: none; }
.pl-title { font-weight: 650; font-size: 1.12rem; }
.pl-desc { color: var(--ink-2); }
.post-list time { font: .8rem var(--mono); color: var(--muted); }
.post-list a:hover .pl-title { text-decoration: underline; text-underline-offset: 4px; }
.list-page { padding: 40px 24px 40px; }
.list-page .lede { margin-bottom: 24px; }

/* Article */
.article { padding: 28px 24px 48px; max-width: 780px; }
.article-head { margin: 12px 0 24px; padding-bottom: 20px; border-bottom: 1px solid var(--ink); }
.byline { font-size: .9rem; color: var(--muted); margin: 14px 0 0; }
.tool-callout { background: var(--paper); border: 1px solid var(--rule); border-left: 4px solid var(--red); padding: 16px 18px; margin: 0 0 28px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.tool-callout p { margin: 0; flex: 1 1 280px; }
.btn { display: inline-block; background: var(--ink); color: #fff; text-decoration: none; padding: 10px 16px; font-weight: 600; font-size: .95rem; }
.btn:hover { background: var(--red-ink); color: #fff; }
.prose { font-size: 1.05rem; }
.prose h2 { margin-top: 38px; }
.prose h3 { margin: 28px 0 8px; }
.prose p, .prose li { max-width: 68ch; }
.prose table { display: block; overflow-x: auto; max-width: 100%; border-collapse: collapse; background: var(--paper); font-size: .93rem; margin: 18px 0; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose td { min-width: 6.5em; }
.prose th { border-bottom: 1px solid var(--ink); font-weight: 600; }
.prose td:not(:first-child) { font-family: var(--mono); font-size: .88rem; }
.prose blockquote { margin: 20px 0; padding: 4px 18px; border-left: 3px solid var(--ink); background: var(--paper); }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--paper); padding: 1px 4px; }
.sources { margin-top: 36px; font-size: .92rem; }
.sources h2, .more h2 { font-size: 1.15rem; }
.sources ul { padding-left: 18px; }
.disclaimer { font-size: .88rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 12px; margin-top: 26px; }
.more { margin-top: 32px; }
.more ul { padding-left: 18px; }
.more li { margin: 4px 0; }
.how { max-width: 780px; margin-top: 52px; }
.static { min-height: 50vh; }
.contact-pending { background: var(--paper); border: 1px dashed var(--rule); padding: 12px 14px; }

/* Footer */
.foot { margin-top: 64px; background: var(--ink); color: #c9ccd2; font-size: .92rem; }
.foot a { color: #fff; }
.foot-in { display: grid; grid-template-columns: 2fr 1fr; gap: 32px; padding-top: 36px; padding-bottom: 18px; }
.foot-brand { font-size: 1.25rem; font-stretch: 80%; color: #fff; margin: 0 0 6px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; align-content: start; }
.foot-copy { color: #8b9099; font: .8rem var(--mono); padding-bottom: 28px; margin: 0 auto; }

@media (max-width: 900px) {
  .tool-grid { grid-template-columns: 1fr; }
  .slip-col { position: static; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .top-in { flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 10px; }
  .nav { width: calc(100% + 32px); margin: 0 -16px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 10px 10px; }
  .hero { padding: 28px 0 36px; }
  .tool-page, .article, .list-page { padding-left: 16px; padding-right: 16px; }
  .block { padding: 36px 16px 4px; }
  .invoice { padding: 20px 16px 22px; }
  .inv-table th:nth-child(3), .inv-table td:nth-child(3) { display: none; }
  .inv-table td { font-size: .9rem; }
  .inv-total { padding-top: 62px; }
  .stamp b { font-size: 1rem; }
  .foot-in { grid-template-columns: 1fr; }
}
@media (max-width: 380px) { .pair { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
