:root {
  --bg: #f4efe6;
  --paper: #fffcf7;
  --ink: #1c1917;
  --muted: #5c534a;
  --line: #ddd4c6;
  --cta: #c24a16;
  --cta-hover: #9a3a10;
  --link: #9a3a10;
  --link-hover: #7a2c0c;
  --trust: #1f5c4c;
  --trust-soft: #e6f0ec;
  --warn-bg: #f8efe4;
  --warn-border: #d9a15c;
  --max: 42rem;
  --wide: 68rem;
  --sans: "Segoe UI", "Helvetica Neue", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --shadow: 0 10px 30px rgba(28, 25, 23, 0.07);
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--sans);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 20;
}
.skip:focus { left: 0.75rem; top: 0.75rem; }

.wrap { width: min(var(--wide), calc(100% - 1.5rem)); margin: 0 auto; }

/* Header and wordmark */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  padding: 0.85rem 0;
  position: sticky;
  top: 0;
  z-index: 15;
}
.header-inner { display: grid; gap: 0.35rem; }
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
}
.logo-mark {
  width: 2rem;
  height: 2rem;
  flex: none;
}
.logo-word {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.tag { margin: 0; color: var(--muted); max-width: 40rem; font-size: 0.92rem; }
.header-actions { display: flex; align-items: center; gap: 0.6rem; }

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
}
nav a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
nav a:hover, nav a[aria-current="page"] { text-decoration: underline; color: var(--link-hover); }

.nav-toggle {
  display: none;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
}
.nav-toggle span,
.nav-toggle span:before,
.nav-toggle span:after {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: var(--ink);
  margin: 0 auto;
  position: relative;
  content: "";
}
.nav-toggle span:before { position: absolute; top: -6px; }
.nav-toggle span:after { position: absolute; top: 6px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span:before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:after { top: 0; transform: rotate(-45deg); }

body.page-invoice-generator .header-cta { display: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.2;
}
.btn-primary { background: var(--cta); color: #fff; }
.btn-primary:hover { background: var(--cta-hover); color: #fff; }
.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-ghost {
  background: transparent;
  color: var(--link);
  border-color: transparent;
  padding-left: 0.7rem;
  padding-right: 0.7rem;
}
.btn-ghost:hover { text-decoration: underline; color: var(--link-hover); }
.btn-small { font-size: 0.9rem; padding: 0.4rem 0.8rem; font-weight: 650; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid var(--cta);
  outline-offset: 2px;
}

main { padding: 0 0 3.5rem; }
.page-pad { padding-top: 2rem; }
main.page-index {
  width: 100%;
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
.page-index .home-body {
  width: min(var(--wide), calc(100% - 1.5rem));
  margin-left: auto;
  margin-right: auto;
}
.prose { max-width: var(--max); }
.page-tools .prose,
.page-index .prose,
.page-invoice-generator .prose,
.home-body { max-width: var(--wide); }

h1, h2, h3, h4 {
  font-family: var(--serif);
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 700;
}
h1 { font-size: clamp(1.85rem, 3.4vw, 2.6rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.45rem; margin: 2rem 0 0.7rem; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
p, li { color: var(--ink); }
.byline, .meta { color: var(--muted); font-size: 0.92rem; }
.byline { margin: 0 0 1.4rem; }

a { color: var(--link); }
a:hover { color: var(--link-hover); }

.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin: 0.3rem 0; }
.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--cta);
  color: var(--muted);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--paper);
  margin: 1rem 0 1.5rem;
}
.prose th, .prose td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.prose th { background: #efe7d8; font-weight: 650; }
.prose tr:nth-child(even) td { background: #fbf7ef; }
.prose code, footer code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #f3e0c8;
  padding: 0.05em 0.3em;
  border-radius: 3px;
}
.prose pre {
  overflow: auto;
  background: #1c1917;
  color: #f6f1e8;
  padding: 1rem;
  border-radius: 8px;
}
.prose pre code { background: none; color: inherit; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

.page-index { list-style: none; padding: 0; margin: 0; }
ul.page-index > li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.95rem 1.05rem;
  margin: 0 0 0.75rem;
}
.page-index p { margin: 0.35rem 0 0; color: var(--muted); }
.pill {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--trust-soft);
  color: var(--trust);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.more, .catalogue { margin-top: 2.5rem; }
.catalogue h2, .more h2 { margin-top: 0; }

/* Hero */
.hero {
  background:
    radial-gradient(ellipse at top right, rgba(194, 74, 22, 0.12), transparent 46%),
    var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 2.6rem 0 2.8rem;
  margin-bottom: 2rem;
}
.hero-inner { width: min(46rem, calc(100% - 1.5rem)); margin: 0 auto; }
.hero-kicker {
  display: inline-block;
  margin: 0 0 0.9rem;
  color: var(--trust);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero h1 { font-size: clamp(2rem, 6vw, 3.15rem); margin-bottom: 0.75rem; }
.hero-lead {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 36rem;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.2rem;
  margin: 1.4rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.95rem;
}
.trust-row li { position: relative; padding-left: 1.2rem; }
.trust-row li:before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--trust);
}

.faq details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  margin: 0 0 0.6rem;
}
.faq summary {
  cursor: pointer;
  font-weight: 700;
}
.faq details p { margin: 0.6rem 0 0.2rem; }

/* Generator */
.gen-intro { max-width: 46rem; }
.promo-tools {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 0 0 1.4rem;
  color: var(--muted);
}
.generator { margin-top: 0.4rem; }
.gen-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  position: sticky;
  top: 4.2rem;
  z-index: 8;
  background: rgba(244, 239, 230, 0.94);
  padding: 0.65rem 0;
  backdrop-filter: blur(8px);
}
.save-status { margin: 0; color: var(--muted); font-size: 0.9rem; }
.gen-warnings {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0 0 1rem;
}
.gen-warnings p { margin: 0 0 0.4rem; }
.gen-warnings ul { margin: 0; }
.gen-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.95fr);
  gap: 1.4rem;
  align-items: start;
}
.gen-form fieldset {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  margin: 0 0 1rem;
  padding: 1rem 1rem 1.1rem;
}
.gen-form legend {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0 0.35rem;
}
.field { margin: 0.7rem 0 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.field label, .gst-toggle > label { display: block; font-weight: 650; margin-bottom: 0.25rem; }
.field-hint { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.88rem; }
.gst-toggle { margin-top: 0.5rem; }
.gst-toggle input { margin-right: 0.4rem; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #cfc4b3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 4.5rem; }
.line-table-wrap { overflow-x: auto; margin-top: 0.6rem; }
.line-editor { width: 100%; border-collapse: collapse; }
.line-editor th { text-align: left; font-size: 0.82rem; color: var(--muted); padding: 0.2rem 0.3rem; }
.line-editor td { padding: 0.3rem; vertical-align: middle; }
.line-editor .line-desc { min-width: 10rem; }
.line-editor .line-qty { width: 4.6rem; }
.line-editor .line-price { width: 6.5rem; }
.check-cell { display: flex; justify-content: center; }

.preview-label { margin: 0 0 0.7rem; font-size: 1.05rem; }
.invoice-sheet {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.3rem 1.6rem;
  color: var(--ink);
  min-height: 20rem;
}
.sheet-top { display: flex; justify-content: space-between; gap: 1rem; }
.sheet-logo { max-width: 8rem; max-height: 4.2rem; object-fit: contain; display: block; margin-bottom: 0.6rem; }
.sheet-biz { font-weight: 700; margin: 0 0 0.15rem; }
.sheet-abn, .sheet-small { margin: 0 0 0.15rem; color: var(--muted); font-size: 0.92rem; white-space: pre-wrap; }
.sheet-heading {
  font-family: var(--serif);
  font-size: 1.7rem;
  margin: 0 0 0.6rem;
  letter-spacing: -0.03em;
  text-align: right;
}
.sheet-meta dl { margin: 0; }
.sheet-meta div { display: flex; justify-content: flex-end; gap: 0.7rem; margin: 0.1rem 0; font-size: 0.92rem; }
.sheet-meta dt { color: var(--muted); }
.sheet-meta dd { margin: 0; font-weight: 650; }
.sheet-to { margin: 1.2rem 0 1rem; }
.sheet-to h3, .sheet-pay h3, .sheet-notes h3 {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.3rem;
}
.sheet-lines { width: 100%; border-collapse: collapse; margin: 0.4rem 0 1rem; font-size: 0.95rem; }
.sheet-lines th { text-align: left; border-bottom: 1px solid var(--line); padding: 0.4rem 0.3rem; color: var(--muted); font-size: 0.8rem; }
.sheet-lines td { border-bottom: 1px solid #efe7d8; padding: 0.45rem 0.3rem; vertical-align: top; }
.sheet-lines th:nth-child(2), .sheet-lines td:nth-child(2),
.sheet-lines th:nth-child(3), .sheet-lines td:nth-child(3),
.sheet-lines th:nth-child(4), .sheet-lines td:nth-child(4) { text-align: right; white-space: nowrap; }
.sheet-totals { display: flex; flex-direction: column; align-items: flex-end; }
.sheet-totals table { border-collapse: collapse; min-width: 16rem; }
.sheet-totals th, .sheet-totals td { padding: 0.25rem 0 0.25rem 1rem; }
.sheet-totals th { font-weight: 500; text-align: left; color: var(--muted); }
.sheet-totals td { text-align: right; }
.sheet-total th, .sheet-total td { font-weight: 800; font-size: 1.05rem; color: var(--ink); padding-top: 0.5rem; }
.sheet-pay, .sheet-notes { margin-top: 1.1rem; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.6rem 0 2.6rem;
  color: var(--muted);
  font-size: 0.92rem;
  background: #efe9dc;
}
.site-footer p { max-width: 52rem; }

/* 404 */
.not-found {
  text-align: center;
  max-width: 36rem;
  margin: 0 auto;
  padding: 2.5rem 0 3.5rem;
}
.not-found h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.15;
  margin: 0.4rem 0 0.85rem;
}
.not-found p { color: var(--muted); margin: 0 0 1.4rem; }
.not-found .hero-actions { justify-content: center; }

@media (max-width: 900px) {

  .gen-layout { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .tag { display: none; }
  .header-cta { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  nav {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 0.4rem 0 0.7rem;
  }
  nav.is-open { display: flex; }
  nav a { padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
  body.nav-open { overflow: hidden; }
  .hero { padding: 1.8rem 0 2rem; }
  .hero-actions .btn { width: 100%; }
  .prose table { display: block; overflow-x: auto; }
  .gen-toolbar { top: 3.7rem; }
  .line-editor thead { display: none; }
  .line-editor, .line-editor tbody, .line-editor tr, .line-editor td { display: block; width: 100%; }
  .line-editor tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.5rem;
    margin: 0 0 0.6rem;
  }
  .line-editor td { padding: 0.35rem 0; }
  .line-editor td:before {
    content: attr(data-label);
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.15rem;
  }
  .line-editor .line-qty, .line-editor .line-price, .line-editor .line-desc { width: 100%; min-width: 0; }
  .sheet-top { flex-direction: column; }
  .sheet-heading { text-align: left; }
  .sheet-meta div { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  body { background: #fff !important; }
  .site-header,
  .site-footer,
  .skip,
  .gen-toolbar,
  .gen-form,
  .gen-warnings,
  .promo-tools,
  .more,
  .faq,
  .byline,
  .preview-label,
  .hero,
  .catalogue,
  .page-invoice-generator article > h1,
  .page-invoice-generator article > p,
  .page-invoice-generator article > h2 {
    display: none !important;
  }
  main, .wrap, .prose, .gen-layout, .gen-preview-col, .generator, article {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  #invoice-sheet {
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    width: auto;
  }
  @page { size: A4; margin: 12mm; }
}
