:root {
  color-scheme: light;
  --ink: #171a18;
  --dim: #555c53;
  --paper: #f4f2eb;
  --white: #fffef9;
  --line: #d6d7ce;
  --forest: #143f35;
  --amber: #e1bd7a;
  --error: #8c321f;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 1.5rem; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.55; }
a { color: inherit; }
:focus-visible { outline: 3px solid #a56821; outline-offset: 3px; }
.wrap { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }
.skip { position: absolute; z-index: 2; inset: .5rem auto auto .5rem; background: var(--white); padding: .75rem; transform: translateY(-150%); }
.skip:focus { transform: translateY(0); }
.top { background: var(--ink); color: var(--white); }
.top-inner, .heading, .actions, .footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.top-inner { min-height: 68px; }
.brand { text-decoration: none; font-weight: 800; font-size: 1.55rem; letter-spacing: -.05em; }
.brand span { color: var(--amber); }
.back { text-underline-offset: .23em; font-size: .9rem; }
.hero { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: end; gap: clamp(2rem, 7vw, 6rem); padding-block: clamp(3rem, 7vw, 6rem) 2.5rem; }
.eyebrow { color: var(--forest); font-size: .72rem; font-weight: 800; letter-spacing: .13em; margin: 0 0 .75rem; }
.dot { display: inline-block; width: .56em; height: .56em; margin-inline-end: .4em; border-radius: 50%; background: #387360; vertical-align: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { line-height: 1.06; letter-spacing: -.04em; }
h1 { font-size: clamp(2.4rem, 6vw, 5.25rem); margin-bottom: 1.1rem; max-width: 13ch; }
h2 { font-size: clamp(1.55rem, 3.4vw, 2.6rem); margin-bottom: 0; }
h3 { line-height: 1.3; }
.intro { color: var(--dim); max-width: 52ch; margin-bottom: 1.6rem; }
.scope { background: #ebe7d9; padding: 1.35rem; border: 1px solid #dfd5bf; border-radius: 14px; font-size: .92rem; }
.scope p:last-child { margin-bottom: 0; }
.button, .remove { display: inline-flex; align-items: center; gap: .65rem; min-height: 44px; font: inherit; font-weight: 700; border: 1px solid transparent; border-radius: 8px; padding: .55rem .9rem; text-decoration: none; cursor: pointer; }
.button:disabled, .remove:disabled { opacity: .55; cursor: default; }
.primary { background: var(--forest); color: white; }
.primary:hover { background: #1e5749; }
.secondary { background: var(--white); color: var(--forest); border-color: var(--line); }
.secondary:hover, .quiet:hover, .remove:hover { background: #eaece3; }
.quiet, .remove { background: transparent; color: var(--dim); }
.pill { display: inline-block; flex: 0 0 auto; font-size: .75rem; color: var(--forest); background: #e5eee7; border-radius: 999px; padding: .25rem .7rem; font-weight: 750; }
.market { margin-bottom: 2rem; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.market h2 { font-size: clamp(1.3rem, 2.5vw, 1.8rem); }
.choices, .language, .market-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .7rem; }
.choices { margin: .8rem 0; }
.choices a { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .75rem; color: var(--forest); text-decoration: none; font-weight: 700; }
.choices a:hover { text-decoration: underline; }
.choices a[aria-current="true"] { background: var(--forest); color: white; border-color: var(--forest); }
.market-summary { margin: 0 0 .55rem; }
.language { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--line); font-size: .87rem; }
.language-choices { margin: 0; }
.language-note { margin: .5rem 0 0; }
.market .pill { flex-shrink: 1; max-width: 100%; }
.hero h1 { overflow-wrap: anywhere; }
.dashboard-grid, .totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
.dashboard article, .totals > div { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.dashboard h3, .totals dt { margin-bottom: .25rem; font-size: .85rem; color: var(--dim); }
.dashboard article p, .totals dd { margin: 0; font-size: clamp(1.15rem, 2.4vw, 1.75rem); font-weight: 750; font-variant-numeric: tabular-nums; }
.dashboard small, .hint { color: var(--dim); }
.editor { margin-block: 2.5rem; border: 1px solid var(--line); border-radius: 14px; background: var(--white); padding: clamp(1rem, 4vw, 2.25rem); }
.invoice-fields { margin: 1.3rem 0; }
.invoice-fields h3, .saved-drafts h3 { margin-bottom: .45rem; }
.invoice-metadata, .invoice-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.invoice-metadata { margin-bottom: .8rem; }
.invoice-party { display: grid; gap: .65rem; min-width: 0; margin: 0; padding: .8rem; border: 1px solid var(--line); border-radius: 8px; background: #f5f5ee; }
.invoice-party legend { padding-inline: .25rem; color: var(--forest); font-weight: 800; }
.invoice-fields label, .draft-picker label { display: block; min-width: 0; color: var(--dim); font-size: .85rem; font-weight: 700; }
.invoice-fields :is(input, textarea), .draft-picker select { display: block; width: 100%; min-width: 0; min-height: 44px; margin-top: .25rem; border: 1px solid #adb1a6; border-radius: 5px; padding: .45rem .55rem; background: white; color: var(--ink); font: inherit; font-size: 1rem; font-weight: 400; }
.invoice-fields textarea { resize: vertical; }
.saved-drafts { margin-top: 1.35rem; padding: 1rem; border: 1px solid var(--line); border-radius: 8px; background: #f5f5ee; }
.draft-picker { display: grid; gap: .75rem; }
.draft-picker select { max-width: 32rem; }
.draft-picker .actions { gap: .5rem; }
#draft-status { margin: .65rem 0 0; }
#draft-status:empty { display: none; }
.hint { font-size: .87rem; }
.row { min-width: 0; margin: 0 0 .75rem; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; }
.row legend { font-weight: 700; font-size: .82rem; color: var(--forest); padding-inline: .3rem; }
.row-fields { display: grid; grid-template-columns: 1.8fr .7fr 1fr .9fr auto; align-items: end; gap: .6rem; }
.row label { min-width: 0; font-size: .8rem; color: var(--dim); font-weight: 700; }
.row input, .row select { display: block; width: 100%; min-height: 44px; border: 1px solid #adb1a6; border-radius: 5px; margin-top: .2rem; padding: .35rem .45rem; background: #fff; color: var(--ink); font: inherit; font-size: 1rem; }
.row [aria-invalid="true"] { border: 2px solid var(--error); }
.field-error, .notice { color: var(--error); font-size: .87rem; margin: .55rem 0 0; }
.actions { justify-content: flex-start; flex-wrap: wrap; }
.totals .due { background: var(--forest); color: white; border-color: var(--forest); }
.totals .due dt { color: #d9e9df; }
.draft-export { margin-top: 1.35rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.draft-export h3 { margin-bottom: .85rem; }
.logo-controls { display: flex; align-items: flex-start; gap: .85rem; margin-bottom: 1rem; }
.logo-controls > div { min-width: 0; }
.logo-controls label { display: block; font-weight: 700; }
#logo-file { display: block; width: 100%; max-width: 26rem; min-width: 0; min-height: 44px; margin-block: .4rem .5rem; font: inherit; font-size: .87rem; }
#logo-file::file-selector-button { min-height: 40px; margin-inline-end: .5rem; padding-inline: .7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); font: inherit; cursor: pointer; }
#logo-file[aria-invalid="true"] { outline: 2px solid var(--error); outline-offset: 2px; }
.draft-logo { display: block; width: auto; height: auto; max-width: min(30%, 140px); max-height: 72px; object-fit: contain; }
#logo-status, #email-status { margin: .5rem 0 0; }
#logo-status:empty, #email-status:empty { display: none; }
.email-draft { margin-top: .8rem; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
.email-draft summary { min-height: 32px; color: var(--forest); font-weight: 700; cursor: pointer; }
.email-draft textarea { display: block; width: 100%; min-width: 0; margin-top: .7rem; padding: .5rem; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); font: inherit; font-size: .87rem; resize: vertical; }
.print-document { display: none; }
.roadmap { padding: .5rem 0 3rem; }
.roadmap ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin: 1.5rem 0; padding-inline-start: 1.25rem; }
.roadmap li { padding-inline-end: .75rem; }
.roadmap li::marker { color: var(--forest); font-weight: 750; }
.roadmap h3 { font-size: 1rem; margin-bottom: .35rem; }
.roadmap li p { color: var(--dim); font-size: .9rem; }
.footer { border-top: 1px solid var(--line); padding-block: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--dim); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 760px) {
  .wrap { width: min(100% - 2rem, 1120px); }
  .hero { grid-template-columns: 1fr; gap: 1.5rem; }
  .row-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-fields .item { grid-column: 1 / -1; }
}
@media (max-width: 540px) {
  .heading { align-items: flex-start; flex-wrap: wrap; }
  .dashboard-grid, .invoice-metadata, .invoice-parties, .totals, .roadmap ol { grid-template-columns: 1fr; }
  .dashboard-grid, .totals { gap: .45rem; }
  .dashboard article, .totals > div { padding: .7rem .85rem; }
  .totals > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
  .roadmap ol { gap: .35rem; }
  .logo-controls { flex-direction: column; }
  .logo-controls .draft-logo { max-width: 140px; }
}

@media print {
  @page { margin: 16mm; }
  body { background: white; color: black; font-size: 10pt; }
  body > :not(.print-document) { display: none !important; }
  .print-document { display: block; }
  .print-heading { display: flex; justify-content: space-between; gap: 1rem; border-block: 3pt solid var(--forest); border-bottom-width: 1pt; margin-bottom: 1rem; padding-block: .75rem 0; break-inside: avoid; }
  .print-heading h2 { font-size: 19pt; margin-bottom: .35rem; }
  .print-badge { display: inline-block; margin: 0 0 .55rem; padding: .15rem .4rem; border: 1pt solid #866931; color: #523b12; font-size: 8pt; font-weight: 850; letter-spacing: .04em; }
  .print-document .draft-logo { max-width: 42mm; max-height: 22mm; }
  .print-metadata, .print-participants { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; break-inside: avoid; }
  .print-metadata { margin-block: .75rem; border-bottom: .5pt solid #aaa; padding-bottom: .5rem; }
  .print-participants { margin-bottom: 1rem; }
  .print-party { border-inline-start: 1.5pt solid var(--forest); padding-inline-start: .6rem; overflow-wrap: anywhere; }
  .print-party h3 { margin-bottom: .25rem; color: var(--forest); font-size: 10pt; }
  .print-party p { margin-bottom: .25rem; }
  .print-party-name, .print-metadata dd, .print-totals dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
  .print-address { white-space: pre-line; }
  .print-party-ids { margin: .25rem 0 0; }
  .print-party-ids > div { display: flex; flex-wrap: wrap; column-gap: .4rem; }
  .print-party-ids dd { margin: 0; }
  .print-table { width: 100%; border-collapse: collapse; }
  .print-table tr { break-inside: avoid; }
  .print-table th, .print-table td { padding: .35rem; border-bottom: 1px solid #555; text-align: end; }
  .print-table th:first-child, .print-table td:first-child { text-align: start; }
  .print-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: end; break-inside: avoid; }
  .print-totals > div { padding: .3rem; }
  .print-due { border-block: .5pt solid var(--forest); }
}
