/* Billsmith. One sheet of paper, one chalk-line blue, Archivo throughout, a 4/8 px rhythm. */

@font-face {
  font-family: 'Archivo';
  src: url('/assets/fonts/Archivo-VF.woff2') format('woff2');
  font-weight: 400 800;
  font-stretch: 100% 122%;
  font-display: swap;
}
/* The three cuts the PDF uses, so the preview is drawn with the same letters as the download. */
@font-face { font-family: 'BS Regular'; src: url('/assets/fonts/Archivo-Regular.woff2') format('woff2'); font-display: fallback; }
@font-face { font-family: 'BS SemiBold'; src: url('/assets/fonts/Archivo-SemiBold.woff2') format('woff2'); font-display: fallback; }
@font-face { font-family: 'BS BoldX'; src: url('/assets/fonts/Archivo-BoldExpanded.woff2') format('woff2'); font-display: fallback; }

:root {
  --paper: #F5F3EE;
  --paper-deep: #ECE9E2;
  --sheet: #FFFFFF;
  --ink: #15171C;
  --ink-2: #3A404A;
  --muted: #5A606B;
  --faint: #6E7480; /* 4.7:1 on white */
  --rule: #E7E3DA;
  --rule-strong: #CFC9BE;
  --field: #FFFFFF;
  --field-hover: #B9B3A8;
  --accent: #1F55E0;
  --accent-hover: #1947C4;
  --accent-tint: #ECF1FD;
  --error: #B3261E;
  --error-tint: #FDF1EF;
  --ok: #1E7A4C;

  --focus: 0 0 0 3px rgba(31, 85, 224, 0.26);
  --shadow-sheet: 0 1px 1px rgba(21, 23, 28, 0.04), 0 2px 4px rgba(21, 23, 28, 0.03), 0 18px 40px -22px rgba(21, 23, 28, 0.18);
  --shadow-page: 0 1px 1px rgba(21, 23, 28, 0.05), 0 6px 14px -6px rgba(21, 23, 28, 0.12), 0 28px 56px -28px rgba(21, 23, 28, 0.32);
  --shadow-float: 0 2px 4px rgba(21, 23, 28, 0.06), 0 16px 40px -12px rgba(21, 23, 28, 0.28);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --radius: 14px;
  --radius-field: 10px;
  --wrap: 1240px;
  --gutter: 16px;
  color-scheme: light;
}
@media (min-width: 720px) { :root { --gutter: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.55;
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body.sheet-open { overflow: hidden; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; }
a:focus-visible { box-shadow: var(--focus); border-radius: 4px; }
[hidden] { display: none !important; }
svg { flex: none; }

.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 80; text-decoration: none; }
.skip:focus { top: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- Header ---------- */
.site-header { background: var(--paper); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 64px; border-bottom: 1px solid var(--rule); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 28px; height: 28px; }
.brand-tile { fill: var(--ink); }
.brand-b { fill: #fff; }
.brand-line { fill: var(--accent); }
.wordmark { font-weight: 800; font-stretch: 122%; font-variation-settings: 'wdth' 122; font-size: 19px; letter-spacing: -0.012em; }
.site-header nav { display: flex; gap: 24px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 10px 0; }
.site-header nav a:hover { color: var(--ink); }
@media (max-width: 420px) { .site-header nav { gap: 16px; } .site-header nav a { font-size: 14px; } }

/* ---------- Intro ---------- */
.intro { padding-top: 36px; padding-bottom: 28px; }
h1, h2, h3 { margin: 0; line-height: 1.08; letter-spacing: -0.018em; text-wrap: balance; }
h1 { font-size: clamp(32px, 6.4vw, 58px); font-weight: 800; font-stretch: 120%; font-variation-settings: 'wdth' 120; }
h2 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 760; font-stretch: 114%; font-variation-settings: 'wdth' 114; }
h3 { font-size: 18px; font-weight: 700; font-stretch: 108%; font-variation-settings: 'wdth' 108; letter-spacing: -0.01em; }
.lead { font-size: clamp(17px, 1.9vw, 19.5px); line-height: 1.5; color: var(--ink-2); max-width: 52ch; margin: 14px 0 0; text-wrap: pretty; }
.assure { display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; font-size: 14.5px; color: var(--muted); max-width: 62ch; }
.assure svg { width: 18px; height: 18px; margin-top: 2px; fill: none; stroke: var(--ok); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 719px) { .intro { padding-top: 24px; padding-bottom: 20px; } .lead { margin-top: 10px; } }

/* ---------- Tool layout ---------- */
.tool { display: grid; gap: 32px; align-items: start; padding-bottom: 104px; }
@media (min-width: 1080px) {
  .tool { grid-template-columns: minmax(0, 600px) minmax(0, 1fr); gap: 48px; padding-bottom: 72px; }
}

/* ---------- The sheet ---------- */
.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sheet);
  min-width: 0;
}
.doc-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--rule);
  background: linear-gradient(var(--paper), var(--paper)) padding-box;
  background: color-mix(in srgb, var(--paper) 55%, #fff);
  border-radius: var(--radius) var(--radius) 0 0;
}
.currency select { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
.sheet-section { padding: 26px 24px 28px; border-top: 1px solid var(--rule); min-width: 0; }
.doc-bar + .sheet-section { border-top: 0; }
@media (min-width: 560px) { .sheet-section { padding: 30px 32px 32px; } .doc-bar { padding: 16px 32px; } }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-title {
  display: block;
  font-size: 12.5px; line-height: 1.2; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-2); margin: 0 0 18px; font-stretch: 112%; font-variation-settings: 'wdth' 112;
}
.section-body { display: grid; gap: 16px; }
.sheet-section > .section-body + *, .sheet-section .section-body > .section-body { margin: 0; }
.nested { margin-left: 0; }

/* Fields */
.field { display: grid; gap: 7px; min-width: 0; }
.label { font-size: 14px; font-weight: 560; color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.optional { font-size: 12.5px; font-weight: 450; color: var(--faint); }
.hint { font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.45; max-width: 62ch; }
.row-2 { display: grid; gap: 16px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }

input:not([type=checkbox]):not([type=radio]), select, textarea {
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--field);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-field);
  padding: 11px 13px; min-height: 46px; width: 100%; min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
textarea { resize: none; line-height: 1.45; display: block; overflow: hidden; }
input::placeholder, textarea::placeholder { color: #9A9FA8; opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  input:not([type=checkbox]):not([type=radio]):hover, select:hover, textarea:hover { border-color: var(--field-hover); }
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type=date] { min-height: 46px; }
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235A606B' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 18px;
}
.field.invalid input, .field.invalid textarea, .field.invalid .prefix-input { border-color: var(--error); }
.field.invalid input:focus { box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.2); }
.field-error { margin: 2px 0 0; font-size: 13.5px; color: var(--error); font-weight: 520; }

/* Prefixed and suffixed amount inputs */
.prefix-input, .suffix-input { position: relative; display: block; }
.prefix-input > span[aria-hidden], .suffix-input > span[aria-hidden] {
  position: absolute; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-variant-numeric: tabular-nums;
}
.prefix-input > span[aria-hidden] { left: 13px; }
.prefix-input > input:not([type=checkbox]):not([type=radio]) { padding-left: 30px; font-variant-numeric: tabular-nums; }
.suffix-input > span[aria-hidden] { right: 13px; }
.suffix-input > input:not([type=checkbox]):not([type=radio]) { padding-right: 30px; text-align: right; font-variant-numeric: tabular-nums; }

/* Switches */
.switches { display: grid; gap: 14px; padding-top: 4px; }
.switch-row { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.switch-text { display: grid; gap: 3px; padding-top: 2px; }
.switch-label { font-size: 15.5px; font-weight: 600; }
.switch {
  appearance: none; flex: none; width: 46px; height: 28px; margin: 0; border-radius: 999px;
  background: #D9D5CC; position: relative; cursor: pointer;
  transition: background-color 0.2s ease;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.24s var(--ease-out);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { box-shadow: var(--focus); }
.switch-row .hint a { white-space: nowrap; }

.check-row { display: flex; gap: 10px; align-items: center; font-size: 15px; cursor: pointer; min-height: 32px; }
.check-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.check-row.small { font-size: 14px; min-height: 28px; }

/* Segmented controls */
.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  margin: 0; padding: 3px; border: 0; border-radius: 12px;
  background: var(--paper-deep);
}
.segmented label { position: relative; display: block; }
.segmented input, .swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 38px; padding: 6px 16px; border-radius: 9px;
  font-size: 14.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) and (pointer: fine) { .segmented label:hover span { color: var(--ink); } }
.segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(21, 23, 28, 0.1), 0 2px 6px rgba(21, 23, 28, 0.06); }
.segmented input:focus-visible + span { box-shadow: var(--focus); }
.segmented-full { display: grid; width: 100%; }
.segmented-small span { min-height: 34px; font-size: 13.5px; padding: 5px 10px; }
.segmented-small.nested { display: grid; width: 100%; }
@media (max-width: 420px) { .segmented-small span { padding: 5px 6px; font-size: 12.5px; white-space: normal; line-height: 1.2; } }

/* From: the summary a returning visitor sees */
.text-button {
  background: none; border: 0; padding: 6px 2px; font: inherit; font-size: 14.5px; font-weight: 600;
  color: var(--accent); cursor: pointer; border-radius: 6px;
}
.text-button:hover { color: var(--accent-hover); }
.text-button:focus-visible { box-shadow: var(--focus); }
.section-head .section-title { margin-bottom: 18px; }
.from-summary { display: grid; gap: 3px; }
.from-summary strong { font-size: 17px; font-weight: 650; }
.from-summary span { color: var(--muted); font-size: 14.5px; }
.from-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--paper-deep); border-radius: 6px; padding: 3px 8px; }

/* ---------- The job: a ledger ---------- */
.items { display: grid; }
.item {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) 36px; gap: 0 10px; align-items: start;
  padding: 16px 0; border-bottom: 1px solid var(--rule);
}
.item:first-child { padding-top: 0; }
.item-n { font-size: 13px; font-weight: 650; color: var(--faint); padding-top: 34px; font-variant-numeric: tabular-nums; }
.item-body { display: grid; gap: 12px; min-width: 0; }
.item-desc textarea { min-height: 46px; }
.item-grid { display: grid; grid-template-columns: 76px minmax(0, 1fr) minmax(88px, auto); gap: 10px; align-items: end; }
.item-grid.with-vat { grid-template-columns: 70px minmax(0, 1fr) 84px minmax(84px, auto); }
.line-amount { display: grid; gap: 7px; text-align: right; }
.line-amount-value { min-height: 46px; display: flex; align-items: center; justify-content: flex-end; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kind { display: grid; width: 100%; }
.remove-item { margin-top: 28px; }
@media (max-width: 460px) {
  .item { grid-template-columns: minmax(0, 1fr) 36px; }
  .item-n { display: none; }
  .item-grid.with-vat { grid-template-columns: 64px minmax(0, 1fr) 80px; }
  .item-grid.with-vat .line-amount { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
  .item-grid.with-vat .line-amount-value { min-height: 0; }
}
.add-item {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  background: none; border: 0; padding: 10px 2px; min-height: 44px;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--accent); cursor: pointer; border-radius: 8px;
}
.add-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.add-item:hover { color: var(--accent-hover); }
.add-item:focus-visible { box-shadow: var(--focus); }

.ledger { margin-top: 18px; padding: 18px 20px 20px; background: color-mix(in srgb, var(--paper) 60%, #fff); border-radius: 12px; }
.ledger-tax { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--rule); }
.ledger-tax-rate { display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 560; }
.ledger-tax-rate .suffix-input { width: 112px; }
.ledger-tax-name input { width: 180px; }
.ledger-lines { margin: 0; display: grid; gap: 2px; }
.ledger-line { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.ledger-line dt { color: var(--ink-2); }
.ledger-line dd { margin: 0; white-space: nowrap; }
.ledger-line.muted dt, .ledger-line.muted dd { color: var(--muted); }
.ledger-line.strong dt, .ledger-line.strong dd { font-weight: 650; color: var(--ink); }
.ledger-due {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  margin-top: 8px; padding-top: 14px; border-top: 1.5px solid var(--ink);
}
.ledger-lines:empty + .ledger-due { margin-top: 0; padding-top: 4px; border-top: 0; }
.ledger-due-label { font-size: 15px; font-weight: 650; }
.ledger-due-value {
  font-size: clamp(26px, 4vw, 32px); font-weight: 800; font-stretch: 120%; font-variation-settings: 'wdth' 120;
  letter-spacing: -0.015em; color: var(--doc-accent, var(--accent)); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.ledger-note { margin: 12px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }

/* Notes */
#notes textarea { min-height: 46px; }

/* Look: logo and colour */
.look { padding-top: 0; padding-bottom: 0; }
.look summary {
  display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer;
  padding: 22px 0; min-height: 64px;
}
.look summary::-webkit-details-marker { display: none; }
.look summary .section-title { margin: 0; }
.look-peek { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.look-swatch { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.chevron { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s var(--ease-out); }
details[open] > summary .chevron { transform: rotate(180deg); }
.look summary:focus-visible { box-shadow: var(--focus); border-radius: 8px; }
.look-body { display: grid; gap: 20px; padding-bottom: 28px; }
.logo-row { display: flex; gap: 16px; align-items: center; }
.logo-box { width: 112px; height: 72px; border: 1px dashed var(--rule-strong); border-radius: 10px; display: grid; place-items: center; overflow: hidden; background: var(--paper); flex: none; }
.logo-box span { font-size: 13px; color: var(--faint); }
.logo-box img { max-width: 92%; max-height: 88%; object-fit: contain; }
.logo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.logo-actions .hint { width: 100%; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px 4px; border: 0; padding: 0; margin: 0; }
.swatch { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px 0 6px; border-radius: 999px; cursor: pointer; }
.swatch-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); transition: box-shadow 0.15s ease; }
.swatch-name { font-size: 14px; color: var(--muted); }
.swatch input:checked + .swatch-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--swatch); }
.swatch input:checked ~ .swatch-name { color: var(--ink); font-weight: 600; }
.swatch input:focus-visible + .swatch-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--swatch), var(--focus); }

/* ---------- Actions ---------- */
.sheet-actions { padding: 24px; border-top: 1px solid var(--rule); display: grid; gap: 14px; }
@media (min-width: 560px) { .sheet-actions { padding: 28px 32px 30px; } }
.saved { margin: 0; display: flex; gap: 14px; align-items: center; justify-content: center; font-size: 13.5px; color: var(--muted); }
.saved .text-button { font-size: 13.5px; font-weight: 500; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.saved .text-button:hover { color: var(--ink); }

.precheck { border: 1px solid #F0C9C3; background: var(--error-tint); border-radius: 12px; padding: 16px 18px; }
.precheck:focus-visible { box-shadow: var(--focus); }
.precheck-title { margin: 0; font-weight: 650; color: var(--ink); }
.precheck-text { margin: 6px 0 0; font-size: 14.5px; color: var(--ink-2); }
.precheck-list { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); }
.precheck-list li { margin: 2px 0; }
.precheck-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.link-button { background: none; border: 0; padding: 2px 0; font: inherit; font-size: 15px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-align: left; }
.link-button:focus-visible { box-shadow: var(--focus); border-radius: 4px; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 640; font-size: 15.5px; line-height: 1.2;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent; user-select: none;
  transition: transform 0.16s var(--ease-out), background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.button:active { transform: scale(0.97); }
.button:focus-visible { box-shadow: var(--focus); }
.button[disabled] { cursor: progress; }
.button.busy { opacity: 0.7; }
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 1px rgba(21, 23, 28, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
@media (hover: hover) and (pointer: fine) { .button-primary:hover { background: var(--accent-hover); color: #fff; } .button-quiet:hover { border-color: var(--ink-2); } }
.button-quiet { background: #fff; color: var(--ink); border-color: var(--rule-strong); }
.button-small { min-height: 38px; padding: 7px 14px; font-size: 14.5px; border-radius: 10px; }
.button-large { min-height: 54px; font-size: 16.5px; border-radius: 14px; }
.icon-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--faint); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.16s var(--ease-out);
}
.icon-button::before { content: ''; position: absolute; inset: -4px; }
.icon-button { position: relative; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
@media (hover: hover) and (pointer: fine) { .icon-button:hover { background: var(--paper); color: var(--ink); } }
.icon-button:active { transform: scale(0.94); }
.icon-button:focus-visible { box-shadow: var(--focus); color: var(--ink); }

/* ---------- Preview ---------- */
.preview-pane { display: none; }
.preview-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.preview-status { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.preview-title { font-weight: 700; font-size: 16px; }
.preview-meta { color: var(--muted); font-size: 13.5px; }
.badge { font-size: 12px; font-weight: 650; letter-spacing: 0.02em; color: var(--accent-hover); background: var(--accent-tint); border-radius: 6px; padding: 3px 8px; }
.example-note { margin: -4px 0 14px; font-size: 14px; color: var(--muted); }
.pages { display: grid; gap: 20px; }
.page { background: #fff; border-radius: 2px; box-shadow: var(--shadow-page); overflow: hidden; }
.page svg { display: block; width: 100%; height: auto; }
.page text { font-kerning: none; font-variant-ligatures: none; }
.sheet-footer, .close-preview { display: none; }

@media (min-width: 1080px) {
  .preview-pane { display: block; position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow: auto; padding: 2px 2px 24px; scrollbar-width: thin; }
  .form-download { display: none; }
}

/* Phone: the preview as a sheet, and a thumb-height action bar */
@media (max-width: 1079.98px) {
  .preview-pane {
    display: flex; flex-direction: column;
    position: fixed; inset: auto 0 0 0; z-index: 50; height: calc(100% - max(28px, env(safe-area-inset-top)));
    background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-float);
    transform: translateY(105%); visibility: hidden;
    transition: transform 0.42s var(--ease-drawer), visibility 0s linear 0.42s;
  }
  .preview-pane.open { transform: translateY(0); visibility: visible; transition: transform 0.42s var(--ease-drawer), visibility 0s; }
  .preview-head { position: relative; padding: 18px var(--gutter) 10px; margin: 0; border-bottom: 1px solid var(--rule); }
  .preview-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--rule-strong); }
  .preview-download { display: none; }
  .close-preview { display: inline-grid; }
  .example-note { margin: 12px var(--gutter) 0; }
  .pages { flex: 1; overflow: auto; padding: 16px var(--gutter) 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .preview-pane.zoomed .page { width: 220%; }
  .preview-pane.zoomed .pages { overflow: auto; }
  .page { cursor: zoom-in; }
  .preview-pane.zoomed .page { cursor: zoom-out; }
  .sheet-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); background: var(--paper);
  }
  .zoom-hint { margin: 0; font-size: 13.5px; color: var(--muted); }
  .sheet-footer .button { flex: none; }

  .mobile-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; gap: 8px; align-items: center;
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: rgba(245, 243, 238, 0.92); border-top: 1px solid var(--rule);
    -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  }
  .mobile-total { flex: 1; display: grid; line-height: 1.15; min-width: 0; }
  .mobile-total .label { font-size: 12px; color: var(--muted); font-weight: 600; }
  .mobile-total-value { font-weight: 800; font-size: 19px; font-stretch: 116%; font-variation-settings: 'wdth' 116; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-bar .button { padding: 10px 14px; }
}
@media (min-width: 1080px) { .mobile-bar { display: none; } }

.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(21, 23, 28, 0.32); opacity: 0; transition: opacity 0.3s ease; }
.scrim.show { opacity: 1; }
@media (min-width: 1080px) { .scrim { display: none; } }

/* ---------- Ready: the one moment that matters ---------- */
.done {
  position: fixed; z-index: 60; right: 24px; bottom: 24px; width: min(420px, calc(100vw - 32px));
  background: #fff; border: 1px solid var(--rule); border-radius: 16px; box-shadow: var(--shadow-float);
  padding: 16px 16px 16px 18px;
  opacity: 0; transform: translateY(14px) scale(0.98); transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.done.show { opacity: 1; transform: none; transition: opacity 0.32s var(--ease-out), transform 0.42s var(--ease-out); }
.done-head { display: flex; gap: 12px; align-items: flex-start; }
.done-icon { flex: none; width: 32px; height: 32px; border-radius: 50%; background: #E8F3EC; display: grid; place-items: center; }
.done-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--ok); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.done-icon path { stroke-dasharray: 20; stroke-dashoffset: 20; }
.done.show .done-icon path { stroke-dashoffset: 0; transition: stroke-dashoffset 0.42s var(--ease-out) 0.12s; }
.done-text { display: grid; gap: 2px; flex: 1; min-width: 0; padding-top: 4px; }
.done-text strong { font-size: 16px; font-weight: 700; }
.done-text span { font-size: 14.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.done-close { margin: -4px -6px 0 0; }
.done-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-left: 44px; }
@media (max-width: 1079.98px) {
  .done { left: 12px; right: 12px; width: auto; bottom: calc(78px + env(safe-area-inset-bottom)); transform-origin: bottom center; }
  .done-actions { padding-left: 0; }
  .done-actions .button { flex: 1 1 auto; }
}

/* Toast with an Undo */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 70;
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: #fff; padding: 12px 14px 12px 18px; border-radius: 14px; font-size: 14.5px;
  max-width: min(92vw, 560px); box-shadow: var(--shadow-float);
  opacity: 0; pointer-events: none; transform: translate(-50%, 10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); transition: opacity 0.28s var(--ease-out), transform 0.36s var(--ease-out); }
.toast-action { background: none; border: 0; color: #9DB7FF; font: inherit; font-weight: 650; padding: 8px 6px; cursor: pointer; border-radius: 8px; flex: none; }
.toast-action:focus-visible { box-shadow: 0 0 0 3px rgba(157, 183, 255, 0.4); }
@media (min-width: 1080px) { .toast { bottom: 28px; } }

/* ---------- Guide and questions ---------- */
.guide, .faq { padding-top: 64px; }
.guide h2, .faq h2 { max-width: 20ch; }
.guide-grid { display: grid; gap: 32px; margin-top: 28px; }
@media (min-width: 820px) { .guide-grid { grid-template-columns: 1fr 1fr; gap: 40px 64px; } }
.guide article { max-width: 60ch; scroll-margin-top: 24px; }
.guide article p, .guide article li { color: var(--ink-2); font-size: 15.5px; }
.guide article p { margin: 10px 0 0; }
.guide article ul { margin: 10px 0 0; padding-left: 20px; }
.guide article li { margin: 4px 0; }
.example { margin-top: 16px; border-collapse: collapse; width: 100%; max-width: 380px; font-size: 15px; font-variant-numeric: tabular-nums; }
.example caption { text-align: left; font-size: 13.5px; color: var(--muted); padding-bottom: 6px; }
.example th { text-align: left; font-weight: 400; color: var(--ink-2); padding: 7px 0; border-bottom: 1px solid var(--rule); }
.example td { text-align: right; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.example .strong th, .example .strong td { color: var(--ink); font-weight: 700; border-bottom: 0; border-top: 1.5px solid var(--ink); }

.faq { padding-bottom: 88px; }
.faq h2 { margin-bottom: 18px; }
.faq details { border-top: 1px solid var(--rule); max-width: 780px; }
.faq details:last-of-type { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; padding: 18px 0; min-height: 56px; font-weight: 620; font-size: 17px; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-radius: 6px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary:focus-visible { box-shadow: var(--focus); }
.faq details p { margin: 0 0 18px; color: var(--ink-2); max-width: 64ch; }

/* ---------- Footer ---------- */
.site-footer { padding: 0 0 calc(104px + env(safe-area-inset-bottom)); font-size: 14px; color: var(--muted); }
.footer-row { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; border-top: 1px solid var(--rule); padding-top: 24px; }
.footer-row p { margin: 0; max-width: 62ch; }
.footer-row nav { display: flex; gap: 20px; }
.footer-row a { color: var(--muted); }
.footer-row a[aria-current] { color: var(--ink); }
@media (min-width: 1080px) { .site-footer { padding-bottom: 40px; } }

/* ---------- Legal pages ---------- */
.legal { max-width: 760px; padding-top: 48px; padding-bottom: 80px; }
.legal h1 { font-size: clamp(32px, 5vw, 46px); margin-bottom: 10px; }
.legal h2 { font-size: 20px; margin: 36px 0 8px; font-stretch: 108%; font-variation-settings: 'wdth' 108; }
.legal p, .legal li { color: var(--ink-2); max-width: 66ch; }
.legal .updated { color: var(--muted); font-size: 14px; margin-top: 0; }
body:has(.legal) .site-footer { padding-bottom: 40px; }

/* ---------- Reduced motion: keep colour and opacity, drop movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .done, .done.show, .toast, .toast.show { transform: none; }
  .toast { transform: translateX(-50%); }
  .toast.show { transform: translateX(-50%); }
  .button:active, .icon-button:active { transform: none; }
}

/* Phones: the two switchers become two full-width rows instead of wrapping ragged */
@media (max-width: 559px) {
  .doc-bar .segmented { display: grid; width: 100%; }
  .doc-bar .currency { width: 100%; }
}

/* What shows is decided by flags on <html>, set before the first paint by boot.js and kept in step by
   generator.js. An element shows only when every flag in its data-show list is on. */
html.js:not(.f-gb) [data-show~="gb"],
html.js:not(.f-us) [data-show~="us"],
html.js:not(.f-other) [data-show~="other"],
html.js:not(.f-notgb) [data-show~="notgb"],
html.js:not(.f-invoice) [data-show~="invoice"],
html.js:not(.f-quote) [data-show~="quote"],
html.js:not(.f-vat) [data-show~="vat"],
html.js:not(.f-cis) [data-show~="cis"],
html.js:not(.f-gb-invoice) [data-show~="gb-invoice"],
html.js:not(.f-supply) [data-show~="supply"] { display: none !important; }
html.js:not(.f-collapsed) #from-summary, html.js:not(.f-collapsed) #from-edit { display: none !important; }
html.js.f-collapsed #from-fields { display: none !important; }
html.js.f-collapsed #from-summary { min-height: 52px; }
