:root {
  color-scheme: light;
  --ink: #171a18;
  --ink-2: #292d2a;
  --paper: #f4f0e7;
  --paper-2: #e9e3d7;
  --panel: #fffdf8;
  --muted: #62645d;
  --line: rgba(23, 26, 24, .14);
  --line-dark: rgba(255, 255, 255, .13);
  --acid: #d8ff57;
  --violet: #5a52e6;
  --violet-soft: #e9e7ff;
  --amber: #ffca6c;
  --good: #2b8a61;
  --good-soft: #dff3e8;
  --bad: #a7463d;
  --bad-soft: #ffe7e2;
  --shadow: 0 32px 90px rgba(15, 18, 16, .16);
}

* { box-sizing: border-box; }
html { min-width: 280px; scroll-behavior: smooth; background: var(--paper); }
body {
  min-width: 280px;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #4c78ff; outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  border-radius: 9px;
  background: white;
  color: var(--ink);
  padding: 9px 13px;
  font-weight: 850;
}
.skip-link:focus { transform: none; }

.app-header {
  position: sticky;
  z-index: 80;
  top: 0;
  min-height: 70px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid rgba(255,255,255,.11);
  background: rgba(23,26,24,.97);
  color: white;
  padding: 10px clamp(16px, 2.7vw, 42px);
  backdrop-filter: blur(16px);
}

.brand { display: inline-flex; align-items: center; gap: 9px; color: inherit; font-weight: 900; letter-spacing: -.04em; text-decoration: none; }
.brand > span { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; background: var(--acid); color: var(--ink); font-size: .82rem; letter-spacing: 0; }
.product-name { display: grid; border-left: 1px solid rgba(255,255,255,.16); padding-left: 18px; line-height: 1.15; }
.product-name span { color: rgba(255,255,255,.45); font: 850 .58rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.product-name strong { margin-top: 3px; font-size: .82rem; }
.header-actions { min-width: 0; display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.header-button {
  min-height: 35px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: transparent;
  color: rgba(255,255,255,.75);
  padding: 7px 11px;
  font-size: .69rem;
  font-weight: 780;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.header-button:hover:not(:disabled) { border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.07); color: white; }
.header-button:disabled { cursor: not-allowed; opacity: .36; }
.header-button--file { position: relative; overflow: hidden; cursor: pointer; }
.header-button--file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.header-button--file:focus-within { outline: 3px solid #4c78ff; outline-offset: 3px; }
.header-button--quiet { border-color: transparent; }
.truth-badges { display: flex; gap: 5px; }
.truth-badges span { border: 1px solid rgba(216,255,87,.24); border-radius: 5px; background: rgba(216,255,87,.07); color: var(--acid); padding: 5px 7px; font: 850 .55rem/1 ui-monospace, monospace; letter-spacing: .04em; }

.studio-shell {
  min-height: 720px;
  height: calc(100svh - 70px);
  display: grid;
  grid-template-columns: minmax(430px, 510px) minmax(0, 1fr);
  background: var(--ink);
}

.editor-panel {
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line-dark);
  background: var(--panel);
  scrollbar-color: rgba(23,26,24,.24) transparent;
}
.editor-intro { padding: 34px clamp(20px, 3vw, 38px) 28px; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font: 850 .62rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .13em; }
.editor-intro h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.25rem, 3.4vw, 3.45rem); font-weight: 500; letter-spacing: -.058em; line-height: .93; }
.editor-intro h1 em { color: var(--violet); font-weight: 500; }
.editor-intro > p:last-child { max-width: 48ch; margin: 17px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.62; }

.mobile-view-toggle { display: none; }
.step-nav { position: sticky; z-index: 8; top: 0; display: grid; grid-template-columns: repeat(3,1fr); border-block: 1px solid var(--line); background: rgba(255,253,248,.94); padding: 8px clamp(16px, 2vw, 30px); backdrop-filter: blur(13px); }
.step-nav button { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 9px; background: transparent; padding: 8px; color: var(--muted); font-size: .7rem; font-weight: 820; cursor: pointer; }
.step-nav button:hover { background: #f1eee7; color: var(--ink); }
.step-nav span { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: var(--violet-soft); color: var(--violet); font: 850 .58rem/1 ui-monospace, monospace; }

.editor-section { border-bottom: 1px solid var(--line); padding: 27px clamp(18px, 2.6vw, 34px) 31px; scroll-margin-top: 58px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.section-heading > div:first-child { display: flex; align-items: baseline; gap: 10px; }
.section-heading > div:first-child > span { color: var(--violet); font: 850 .61rem/1 ui-monospace, monospace; }
.section-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.5rem; font-weight: 500; letter-spacing: -.035em; }
.section-heading small { max-width: 170px; color: var(--muted); font-size: .63rem; text-align: right; }
.section-heading--actions { align-items: center; }
.section-heading--actions > div:last-child { display: flex; gap: 6px; }

fieldset { min-width: 0; margin: 0; }
.party-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.party-card { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; gap: 11px; border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 15px; }
.party-card legend { padding: 0 6px; color: var(--muted); font: 850 .58rem/1 ui-monospace, monospace; letter-spacing: .09em; }
.field { min-width: 0; display: grid; align-content: start; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field > span:first-child { color: var(--muted); font-size: .63rem; font-weight: 820; }
.field input, .field textarea, .field select, .suffix-input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf6;
  color: var(--ink);
}
.field input, .field select { height: 39px; padding: 0 10px; }
.field textarea { resize: vertical; padding: 9px 10px; line-height: 1.42; }
.field input::placeholder, .field textarea::placeholder { color: #aaa99f; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(90,82,230,.11); background: white; }
.field [aria-invalid="true"] { border-color: var(--bad); background: #fff9f7; }
.logo-control { grid-column: 1 / -1; display: flex; align-items: stretch; gap: 7px; }
.logo-control label { min-width: 0; flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px dashed var(--line); border-radius: 10px; background: #fbfaf6; padding: 9px 10px; cursor: pointer; }
.logo-control label span { color: var(--muted); font-size: .62rem; font-weight: 820; }
.logo-control label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .66rem; }
.logo-control input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.logo-control label:focus-within { outline: 3px solid #4c78ff; outline-offset: 3px; }
.logo-control button { border: 1px solid var(--line); border-radius: 10px; background: white; padding: 0 10px; font-size: .62rem; font-weight: 820; cursor: pointer; }

.meta-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.color-input { min-height: 39px; display: grid; grid-template-columns: 38px minmax(0,1fr); align-items: center; overflow: hidden; }
.color-input input { width: 38px; height: 39px; border: 0; border-radius: 0; background: transparent; padding: 4px; cursor: pointer; }
.color-input b { overflow: hidden; padding-inline: 8px; color: var(--muted); font: 800 .6rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; }
.mini-button { min-height: 34px; border: 1px solid var(--line); border-radius: 999px; background: white; padding: 7px 10px; font-size: .64rem; font-weight: 820; cursor: pointer; }
.mini-button:hover { border-color: var(--violet); }
.mini-button--dark { border-color: var(--ink); background: var(--ink); color: white; }

.items-head, .item-row { display: grid; grid-template-columns: minmax(135px,1fr) 58px 86px 92px 32px; gap: 7px; align-items: center; }
.items-head { padding: 0 7px 7px; color: var(--muted); font-size: .57rem; font-weight: 850; text-transform: uppercase; letter-spacing: .07em; }
.items-head span:nth-child(n+2):not(:last-child) { text-align: right; }
.items-list { display: grid; gap: 7px; }
.item-row { border: 1px solid var(--line); border-radius: 12px; background: white; padding: 7px; }
.item-row input { min-width: 0; width: 100%; height: 37px; border: 0; border-radius: 7px; background: #f7f5ef; padding: 0 8px; color: var(--ink); }
.item-row input:focus { outline: 2px solid var(--violet); background: white; }
.item-row input[data-item-field="quantity"], .item-row input[data-item-field="rate"] { text-align: right; font-variant-numeric: tabular-nums; }
.item-amount { overflow: hidden; color: var(--ink); font-size: .7rem; font-weight: 850; text-align: right; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.remove-item { width: 31px; height: 31px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; }
.remove-item:hover:not(:disabled) { background: var(--bad-soft); color: var(--bad); }
.remove-item:disabled { opacity: .25; cursor: not-allowed; }
.item-limit { display: flex; justify-content: space-between; gap: 12px; margin: 9px 2px 0; color: var(--muted); font-size: .58rem; }

.money-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.suffix-input { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; overflow: hidden; }
.suffix-input:focus-within { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(90,82,230,.11); }
.suffix-input input { border: 0; background: transparent; box-shadow: none !important; }
.suffix-input b { padding-right: 10px; color: var(--muted); font-size: .68rem; }
.check-field { display: flex; align-items: flex-start; gap: 10px; margin-top: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfaf6; padding: 11px; cursor: pointer; }
.check-field input { flex: 0 0 auto; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--violet); }
.check-field strong, .check-field small { display: block; }
.check-field strong { font-size: .69rem; }
.check-field small { margin-top: 2px; color: var(--muted); font-size: .59rem; line-height: 1.4; }
.finish-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-top: 13px; }
.payment-pack { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px 12px; align-items: end; margin-top: 13px; border: 1px solid rgba(90,82,230,.2); border-radius: 14px; background: linear-gradient(135deg,#f4f2ff,#fffdf8); padding: 13px; }
.payment-pack-actions { display: flex; align-items: center; gap: 7px; }
.payment-pack-actions button,.payment-pack-actions a { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); padding: 8px 11px; font-size: .64rem; font-weight: 830; text-decoration: none; cursor: pointer; white-space: nowrap; }
.payment-pack-actions button:disabled { cursor: not-allowed; opacity: .42; }
.payment-pack > p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .59rem; line-height: 1.45; }
.payment-pack[data-state="ready"] { border-color: rgba(43,138,97,.27); background: linear-gradient(135deg,#edf9f2,#fffdf8); }
.payment-pack[data-state="error"] { border-color: rgba(167,70,61,.28); background: linear-gradient(135deg,#fff1ee,#fffdf8); }
.check-field--privacy { border-color: rgba(43,138,97,.23); background: var(--good-soft); }
.data-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.data-actions button { border: 0; background: transparent; padding: 4px; color: var(--muted); font-size: .61rem; font-weight: 780; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.editor-dock { position: sticky; z-index: 10; bottom: 0; display: grid; grid-template-columns: minmax(105px,.72fr) minmax(190px,1.28fr); gap: 10px; border-top: 1px solid var(--line); background: rgba(255,253,248,.97); padding: 14px clamp(17px,2.6vw,34px) max(14px,env(safe-area-inset-bottom)); box-shadow: 0 -16px 35px rgba(23,26,24,.08); backdrop-filter: blur(16px); }
.dock-total { min-width: 0; display: grid; align-content: center; line-height: 1.1; }
.dock-total span { color: var(--muted); font: 850 .55rem/1 ui-monospace, monospace; letter-spacing: .09em; }
.dock-total strong { overflow: hidden; margin-top: 5px; font-family: Georgia, "Times New Roman", serif; font-size: 1.38rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dock-total small { margin-top: 4px; color: var(--muted); font-size: .56rem; }
.download-button { min-width: 0; min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-radius: 14px; background: var(--ink); color: white; padding: 9px 10px 9px 16px; font-size: .74rem; font-weight: 850; cursor: pointer; }
.download-button i { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 10px; background: var(--acid); color: var(--ink); font-size: 1rem; font-style: normal; }
.download-button:hover:not(:disabled) { background: #292e2a; }
.download-button:disabled { cursor: wait; opacity: .56; }
.editor-dock > p { grid-column: 2; margin: -5px 0 0; color: var(--muted); font-size: .54rem; text-align: center; }

.preview-panel {
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #202420;
  color: white;
  padding: 22px clamp(20px, 3vw, 44px) 30px;
  scrollbar-color: rgba(255,255,255,.22) transparent;
}
.preview-toolbar { position: sticky; z-index: 12; top: -22px; display: grid; grid-template-columns: minmax(150px,1fr) auto auto auto; align-items: center; gap: 14px; margin: -22px clamp(-44px,-3vw,-20px) 0; border-bottom: 1px solid var(--line-dark); background: rgba(32,36,32,.96); padding: 18px clamp(20px,3vw,44px) 15px; backdrop-filter: blur(15px); }
.preview-toolbar .eyebrow { color: rgba(255,255,255,.44); }
.preview-toolbar h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 500; letter-spacing: -.035em; }
.template-switch { display: flex; border: 1px solid var(--line-dark); border-radius: 999px; padding: 3px; }
.template-switch button { min-height: 30px; border: 0; border-radius: 999px; background: transparent; color: rgba(255,255,255,.55); padding: 5px 9px; font-size: .61rem; font-weight: 820; cursor: pointer; }
.template-switch button[aria-pressed="true"] { background: white; color: var(--ink); }
.zoom-controls { display: flex; align-items: center; gap: 3px; }
.zoom-controls button { width: 30px; height: 30px; border: 1px solid var(--line-dark); border-radius: 9px; background: transparent; color: white; cursor: pointer; }
.zoom-controls output { min-width: 38px; color: rgba(255,255,255,.58); font: 750 .58rem/1 ui-monospace, monospace; text-align: center; }
.page-count { border: 1px solid var(--line-dark); border-radius: 999px; padding: 7px 9px; color: rgba(255,255,255,.55); font-size: .59rem; font-weight: 800; white-space: nowrap; }

.preflight-bar { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 7px; margin: 17px 0; }
.preflight-chip { min-width: 0; display: flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,.13); border-radius: 10px; background: rgba(255,255,255,.045); color: rgba(255,255,255,.68); padding: 8px 9px; font-size: .61rem; font-weight: 760; text-align: left; cursor: pointer; }
.preflight-chip span { display: grid; flex: 0 0 auto; width: 18px; height: 18px; place-items: center; border-radius: 50%; font-size: .58rem; }
.preflight-chip[data-status="pass"] span { background: rgba(72,205,143,.16); color: #76e5af; }
.preflight-chip[data-status="warn"] { border-color: rgba(255,202,108,.35); background: rgba(255,202,108,.08); color: #ffe0a9; }
.preflight-chip[data-status="warn"] span { background: rgba(255,202,108,.16); color: var(--amber); }

.preview-stage { min-height: calc(100% - 210px); overflow: auto; border: 1px solid rgba(255,255,255,.11); border-radius: 24px; background: #151815; padding: clamp(24px, 4vw, 56px); box-shadow: inset 0 1px rgba(255,255,255,.04); }
.preview-pages { --preview-width: 86%; width: var(--preview-width); max-width: 760px; min-width: 260px; display: grid; gap: 24px; margin-inline: auto; transition: width .18s ease; }
.invoice-paper { --invoice-accent-color: #272c29; position: relative; container-type: inline-size; width: 100%; aspect-ratio: 210 / 297; overflow: hidden; background: #fff; color: #20231f; padding: 7.3cqw 7.1cqw 5.1cqw; box-shadow: var(--shadow); font-size: 1.45cqw; }
.invoice-paper[data-size="letter"] { aspect-ratio: 8.5 / 11; }
.invoice-paper[data-theme="paper"] { background: #fffdf6; color: #302c27; }
.invoice-paper[data-theme="mono"] { background: white; color: #111; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.invoice-accent { position: absolute; top: 0; left: 0; width: 100%; height: 1.1cqw; background: var(--invoice-accent-color); }
.invoice-paper[data-theme="paper"] .invoice-accent { background: var(--invoice-accent-color); }
.invoice-paper[data-theme="mono"] .invoice-accent { height: .45cqw; background: #111; }
.invoice-top { min-height: 12cqw; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 5cqw; align-items: start; }
.invoice-brand { min-width: 0; display: flex; align-items: flex-start; gap: 2.2cqw; }
.invoice-logo { flex: 0 0 auto; width: 11cqw; height: 7cqw; display: grid; place-items: center; overflow: hidden; border: .12cqw solid rgba(32,35,31,.14); border-radius: 1cqw; background: #faf9f4; }
.invoice-logo img { width: 100%; height: 100%; object-fit: contain; }
.invoice-logo--letters { background: var(--invoice-accent-color); color: white; font: 850 2.3cqw/1 Georgia, serif; }
.invoice-paper[data-theme="paper"] .invoice-logo--letters { background: var(--invoice-accent-color); }
.invoice-paper[data-theme="mono"] .invoice-logo--letters { border-radius: 0; background: #111; }
.invoice-brand-copy { min-width: 0; }
.invoice-brand-copy strong { display: block; overflow: hidden; font-family: Georgia, "Times New Roman", serif; font-size: 2.3cqw; font-weight: 500; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.invoice-paper[data-theme="mono"] .invoice-brand-copy strong { font-family: inherit; font-size: 1.9cqw; font-weight: 850; letter-spacing: -.02em; }
.invoice-brand-copy span { display: block; max-width: 42cqw; margin-top: .8cqw; color: #73756f; font-size: 1.1cqw; white-space: pre-line; }
.invoice-title { text-align: right; }
.invoice-title b { display: block; color: #9b9c96; font: 850 1cqw/1 ui-monospace, monospace; letter-spacing: .18em; }
.invoice-title strong { display: block; margin-top: 1.1cqw; font-family: Georgia, "Times New Roman", serif; font-size: 4.4cqw; font-weight: 500; letter-spacing: -.06em; line-height: .82; }
.invoice-title span { display: block; margin-top: 1.1cqw; color: #666a64; font: 750 1.1cqw/1 ui-monospace, monospace; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr 1.1fr; gap: 3cqw; margin-top: 4.2cqw; border-top: .11cqw solid #d9dad4; padding-top: 3.1cqw; }
.invoice-parties section > span, .invoice-dates dt { display: block; margin-bottom: .9cqw; color: #95968f; font: 850 .95cqw/1 ui-monospace, monospace; letter-spacing: .08em; }
.invoice-parties strong { display: block; font-size: 1.35cqw; }
.invoice-parties p { margin: .55cqw 0 0; color: #6e706a; font-size: 1.05cqw; line-height: 1.45; white-space: pre-line; }
.invoice-dates { display: grid; grid-template-columns: auto auto; gap: 1cqw 1.5cqw; margin: 0; }
.invoice-dates div { display: contents; }
.invoice-dates dt { margin: 0; }
.invoice-dates dd { margin: 0; font-size: 1.06cqw; font-weight: 760; text-align: right; }
.invoice-table { width: 100%; margin-top: 4.3cqw; border-collapse: collapse; table-layout: fixed; }
.invoice-table th { border-bottom: .13cqw solid #242824; padding: 0 1.1cqw 1.2cqw; color: #8d8e88; font: 850 .9cqw/1 ui-monospace, monospace; letter-spacing: .08em; text-align: right; }
.invoice-table th:first-child { width: 54%; text-align: left; }
.invoice-table td { border-bottom: .1cqw solid #e0e1dc; padding: 1.55cqw 1.1cqw; font-size: 1.08cqw; text-align: right; vertical-align: top; }
.invoice-table td:first-child { font-weight: 680; text-align: left; overflow-wrap: anywhere; }
.invoice-table td small { display: block; margin-top: .35cqw; color: #92938d; font-size: .86cqw; }
.invoice-continuation { display: flex; justify-content: space-between; gap: 2cqw; border-bottom: .11cqw solid #d9dad4; padding-bottom: 2.4cqw; }
.invoice-continuation strong { font-family: Georgia, serif; font-size: 2.2cqw; font-weight: 500; }
.invoice-continuation span { color: #7e8079; font: 750 1cqw/1 ui-monospace, monospace; }
.invoice-summary { display: grid; grid-template-columns: minmax(0,1fr) 31cqw; gap: 5cqw; margin-top: 4cqw; }
.invoice-notes { color: #73756f; font-size: 1cqw; line-height: 1.5; }
.invoice-notes strong { display: block; margin-bottom: .7cqw; color: #252824; font-size: 1.05cqw; }
.invoice-notes p { margin: 0 0 1.2cqw; white-space: pre-line; }
.invoice-payment-pack { display: grid; grid-template-columns: minmax(0,1fr) 9.2cqw; gap: 1.8cqw; align-items: start; margin-top: 1.5cqw; }
.invoice-payment-pack p { overflow-wrap: anywhere; }
.invoice-payment-qr { display: grid; gap: .5cqw; justify-items: center; }
.invoice-payment-qr svg { width: 9.2cqw; height: 9.2cqw; border: .45cqw solid white; background: white; box-shadow: 0 0 0 .12cqw #d8d9d4; }
.invoice-payment-qr span { color: #777a73; font: 850 .65cqw/1 ui-monospace, monospace; letter-spacing: .06em; }
.invoice-totals { display: grid; gap: 1cqw; }
.invoice-totals div { display: flex; justify-content: space-between; gap: 2cqw; color: #6f716b; font-size: 1.05cqw; }
.invoice-totals strong { color: #222622; font-weight: 760; font-variant-numeric: tabular-nums; }
.invoice-totals .invoice-total { margin-top: .7cqw; border-top: .13cqw solid #252925; padding-top: 1.6cqw; color: #252925; font-weight: 850; }
.invoice-totals .invoice-total strong { font-family: Georgia, serif; font-size: 2.2cqw; font-weight: 500; letter-spacing: -.04em; }
.invoice-page-footer { position: absolute; right: 7.1cqw; bottom: 3.1cqw; left: 7.1cqw; display: flex; justify-content: space-between; gap: 2cqw; color: #9a9b95; font: 700 .82cqw/1 ui-monospace, monospace; }

.verification-panel { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 11px; align-items: center; margin-top: 15px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: rgba(255,255,255,.045); padding: 12px; }
.verification-panel[data-state="success"] { border-color: rgba(72,205,143,.31); background: rgba(72,205,143,.08); }
.verification-panel[data-state="error"] { border-color: rgba(255,132,112,.35); background: rgba(255,132,112,.08); }
.verification-icon { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; background: rgba(216,255,87,.12); color: var(--acid); font-weight: 900; }
.verification-panel strong { display: block; font-size: .72rem; }
.verification-panel p { margin: 3px 0 0; color: rgba(255,255,255,.54); font-size: .62rem; }
.verification-panel code { color: rgba(255,255,255,.5); font-size: .56rem; }
.legal-boundary { margin: 13px 0 0; color: rgba(255,255,255,.45); font-size: .58rem; line-height: 1.5; }
.legal-boundary strong { color: rgba(255,255,255,.68); }
.preview-export-bar { display: none; }

.proof-section { width: min(1480px,calc(100% - 48px)); display: grid; grid-template-columns: .9fr 1.25fr .8fr; gap: clamp(26px,5vw,80px); margin: 0 auto; padding: clamp(70px,8vw,120px) 0; }
.proof-section h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.5rem,4.8vw,5.5rem); font-weight: 500; letter-spacing: -.065em; line-height: .88; }
.proof-section ol { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.proof-section li { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 15px; border-top: 1px solid var(--line); padding: 18px 0; }
.proof-section li > span { color: var(--violet); font: 850 .62rem/1.7 ui-monospace, monospace; }
.proof-section li strong { font-size: .83rem; }
.proof-section li p, .source-note p { margin: 5px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.55; }
.source-note { align-self: start; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.55); padding: 18px; }
.source-note > strong { font-family: Georgia, serif; font-size: 1.25rem; font-weight: 500; }
.source-note a { display: block; margin-top: 10px; color: var(--violet); font-size: .66rem; font-weight: 820; }
.footer { min-height: 110px; display: flex; align-items: center; justify-content: space-between; gap: 25px; border-top: 1px solid var(--line); padding: 24px max(24px,calc((100vw - 1480px)/2)); }
.footer p { color: var(--muted); font-size: .72rem; }
.footer > a:last-child { color: var(--muted); font-size: .7rem; }

.modal { width: min(620px,calc(100% - 28px)); max-height: calc(100svh - 28px); border: 0; border-radius: 24px; background: transparent; padding: 0; color: var(--ink); }
.modal::backdrop { background: rgba(11,14,12,.72); backdrop-filter: blur(7px); }
.modal-card { display: grid; gap: 15px; margin: 0; border: 1px solid rgba(255,255,255,.3); border-radius: 24px; background: var(--panel); padding: clamp(20px,4vw,34px); box-shadow: 0 35px 100px rgba(0,0,0,.34); }
.modal-head { display: flex; justify-content: space-between; gap: 18px; }
.modal-head h2 { margin: 0; font-family: Georgia, serif; font-size: 2.1rem; font-weight: 500; letter-spacing: -.05em; }
.modal-card > p { margin: 0; color: var(--muted); font-size: .75rem; }
.modal-close { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: white; font-size: 1.3rem; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 7px; }
.modal-actions button { min-height: 40px; border: 1px solid var(--line); border-radius: 11px; background: white; padding: 8px 13px; font-size: .7rem; font-weight: 820; cursor: pointer; }
.modal-actions button:last-child { border-color: var(--ink); background: var(--ink); color: white; }
.inline-message { border: 1px solid rgba(167,70,61,.25); border-radius: 10px; background: var(--bad-soft); color: var(--bad); padding: 9px 11px; font-size: .69rem; }
.history-list { max-height: 430px; display: grid; gap: 8px; overflow-y: auto; }
.history-empty { border: 1px dashed var(--line); border-radius: 12px; padding: 24px; color: var(--muted); text-align: center; font-size: .72rem; }
.history-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 11px; }
.history-row strong, .history-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row span { margin-top: 3px; color: var(--muted); font-size: .63rem; }
.history-row button { border: 0; border-radius: 9px; background: var(--violet-soft); color: var(--violet); padding: 8px 10px; font-size: .64rem; font-weight: 850; cursor: pointer; }
.noscript { margin: 0; background: #fff0d1; padding: 12px; text-align: center; }

@media (max-width: 1180px) {
  .app-header { grid-template-columns: auto auto 1fr; }
  .truth-badges { display: none; }
  .studio-shell { grid-template-columns: minmax(410px,460px) minmax(0,1fr); }
  .party-grid { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .money-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .preview-toolbar { grid-template-columns: minmax(120px,1fr) auto auto; }
  .page-count { display: none; }
  .preflight-bar { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 880px) {
  .app-header { min-height: 58px; grid-template-columns: auto minmax(0,1fr) auto; padding: 8px 12px; }
  .product-name { display: none; }
  .header-actions { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .header-actions::-webkit-scrollbar { display: none; }
  .header-button { flex: 0 0 auto; min-height: 32px; padding: 6px 9px; }
  .header-button { min-height: 44px; }
  .header-button--quiet, #historyButton { display: none; }
  .studio-shell { height: auto; min-height: calc(100svh - 58px); display: block; }
  .studio-shell[data-mobile-view="edit"] .preview-panel { display: none; }
  .studio-shell[data-mobile-view="preview"] .editor-panel { display: none; }
  .editor-panel, .preview-panel { min-height: calc(100svh - 58px); overflow: visible; }
  .mobile-view-toggle { position: sticky; z-index: 30; top: 58px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-block: 1px solid var(--line); background: rgba(255,253,248,.97); padding: 7px 12px; backdrop-filter: blur(14px); }
  .mobile-view-toggle--preview { top: 58px; margin: -22px -20px 16px; border-color: var(--line-dark); background: rgba(32,36,32,.97); }
  .mobile-view-toggle button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: .69rem; font-weight: 850; }
  .mobile-view-toggle button[aria-pressed="true"] { background: var(--ink); color: white; }
  .mobile-view-toggle--preview button { color: rgba(255,255,255,.55); }
  .mobile-view-toggle--preview button[aria-pressed="true"] { background: white; color: var(--ink); }
  .step-nav { top: 108px; }
  .editor-intro { padding-top: 28px; }
  .editor-dock { bottom: 0; }
  .preview-panel { padding: 22px 20px 30px; }
  .studio-shell[data-mobile-view="preview"] .preview-panel { padding-bottom: 118px; }
  .studio-shell[data-mobile-view="preview"] .preview-export-bar { position: fixed; z-index: 45; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: minmax(92px,.66fr) minmax(164px,1.34fr); gap: 10px; align-items: center; border-top: 1px solid var(--line); background: rgba(255,253,248,.97); color: var(--ink); padding: 12px 13px max(12px,env(safe-area-inset-bottom)); box-shadow: 0 -16px 35px rgba(23,26,24,.16); backdrop-filter: blur(16px); }
  .preview-export-bar > div { min-width: 0; display: grid; gap: 2px; }
  .preview-export-bar > div span { color: var(--muted); font: 850 .52rem/1 ui-monospace, monospace; letter-spacing: .08em; }
  .preview-export-bar > div strong { overflow: hidden; font-family: Georgia, serif; font-size: 1.12rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
  .preview-toolbar { position: relative; top: auto; margin: 0 0 14px; grid-template-columns: minmax(120px,1fr) auto; border: 0; background: transparent; padding: 0; }
  .template-switch { grid-column: 1 / -1; justify-self: start; }
  .zoom-controls { grid-column: 2; grid-row: 1; }
  .preview-stage { min-height: 66svh; padding: 24px 14px; }
  .preview-pages { --preview-width: 100%; min-width: 0; }
  .mini-button,.payment-pack-actions button,.payment-pack-actions a,.data-actions button,.template-switch button,.zoom-controls button,.preflight-chip { min-height: 44px; }
  .zoom-controls button { width: 44px; height: 44px; }
  .proof-section { grid-template-columns: 1fr; width: min(100% - 30px,700px); padding-block: 72px; }
  .source-note { max-width: 520px; }
}

@media (max-width: 560px) {
  .app-header .brand { font-size: 0; }
  .app-header .brand > span { width: 34px; height: 34px; font-size: .8rem; }
  #repeatLast, .header-button--file { display: none; }
  .editor-intro h1 { font-size: clamp(2.1rem,11vw,3rem); }
  .party-grid, .finish-grid { grid-template-columns: 1fr; }
  .party-card { grid-template-columns: 1fr; }
  .field--full, .logo-control { grid-column: auto; }
  .meta-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .meta-grid .field:first-child { grid-column: 1 / -1; }
  .items-head { display: none; }
  .item-row { grid-template-columns: minmax(0,1fr) 32px; gap: 7px; }
  .item-row input[data-item-field="description"] { grid-column: 1; }
  .remove-item { grid-column: 2; grid-row: 1; }
  .item-row input[data-item-field="quantity"], .item-row input[data-item-field="rate"], .item-amount { grid-row: 2; }
  .item-row input[data-item-field="quantity"] { grid-column: 1; width: calc(42% - 4px); justify-self: start; }
  .item-row input[data-item-field="rate"] { grid-column: 1; width: calc(58% - 4px); justify-self: end; }
  .item-amount { grid-column: 2; align-self: center; }
  .item-limit { display: grid; }
  .money-grid { grid-template-columns: 1fr 1fr; }
  .payment-pack { grid-template-columns: 1fr; }
  .payment-pack-actions { flex-wrap: wrap; }
  .payment-pack > p { grid-column: auto; }
  .editor-dock { grid-template-columns: minmax(92px,.66fr) minmax(164px,1.34fr); padding-inline: 13px; }
  .download-button { padding-left: 12px; font-size: .67rem; }
  .dock-total strong { font-size: 1.12rem; }
  .preflight-bar { grid-template-columns: 1fr 1fr; }
  .preview-stage { border-radius: 18px; }
  .verification-panel { grid-template-columns: auto minmax(0,1fr); }
  .verification-panel code { grid-column: 1 / -1; }
  .footer { display: grid; justify-items: start; padding-inline: 18px; }
}

@media (max-width: 390px) {
  .editor-intro { padding-inline: 18px; }
  .editor-section { padding-inline: 16px; }
  .section-heading--actions { align-items: start; }
  .section-heading--actions > div:last-child { flex-wrap: wrap; justify-content: flex-end; }
  .preview-panel { padding-inline: 12px; }
  .mobile-view-toggle--preview { margin-left: -12px; margin-right: -12px; }
  .preview-stage { padding-inline: 8px; }
}

@media (max-width: 330px) {
  .editor-section { padding-inline: 14px; }
  .section-heading { display: grid; }
  .section-heading small { max-width: none; text-align: left; }
  .section-heading--actions > div:last-child { width: 100%; }
  .section-heading--actions .mini-button { flex: 1; min-width: 0; }
  .meta-grid, .money-grid { grid-template-columns: 1fr; }
  .meta-grid .field:first-child { grid-column: auto; }
  .editor-dock { grid-template-columns: 1fr; }
  .editor-dock > p { display: none; }
  .download-button { min-height: 50px; }
  .preflight-bar { grid-template-columns: 1fr; }
  .template-switch button { padding-inline: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
