/* Invoiceferry — styles. Tokens first (the only place raw values live), then base, components,
   editor, content pages, and finally the document (preview + PDF) and print styles.
   See DESIGN.md for the system. */

@font-face {
  font-family: 'Plus Jakarta Sans Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('../fonts/plus-jakarta-sans-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===================================================================== tokens */
:root {
  /* spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  /* radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  /* type */
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --font-head: 'Plus Jakarta Sans Variable', var(--font);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;
  --fs-4xl: 2.5rem;
  --fs-h1: clamp(2rem, 1.45rem + 2.2vw, 3rem);
  --lh: 1.55;
  --lh-tight: 1.15;
  /* motion */
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 260ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  /* layout */
  --header-h: 60px;
  --container: 1280px;

  /* colour — light */
  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #f0eef5;
  --surface-3: #e7e4ef;
  --input-bg: #ffffff;
  --border: #e3e0ea;
  --border-strong: #c9c4d4;
  --text: #1c1828;
  --text-muted: #5d5770;
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --accent-soft: #f0eafd;
  --accent-text: #5b21b6;
  --on-accent: #ffffff;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --warning: #a16207;
  --info: #1d4ed8;
  --info-soft: #e8eefc;
  --danger: #c42b2b;
  --danger-hover: #a61f1f;
  --danger-soft: #fdecec;
  --focus: #7c3aed;
  --desk: #e6e3ed;
  --ink: #1c1828; /* toast background */
  --shadow-sm: 0 1px 2px rgba(28, 24, 40, 0.06), 0 2px 8px rgba(28, 24, 40, 0.05);
  --shadow-lg: 0 12px 40px rgba(28, 24, 40, 0.18), 0 2px 6px rgba(28, 24, 40, 0.08);
  --paper-shadow: 0 1px 2px rgba(28, 24, 40, 0.08), 0 10px 30px rgba(28, 24, 40, 0.12);
  color-scheme: light;
}

/* dark theme: explicit user choice (html[data-theme='dark']), never the OS setting */
:root[data-theme='dark'] {
  --bg: #131217;
  --surface: #1b1a21;
  --surface-2: #232229;
  --surface-3: #2c2b34;
  --input-bg: #16151b;
  --border: #2f2d38;
  --border-strong: #46434f;
  --text: #ecebf1;
  --text-muted: #a7a3b4;
  --accent: #a48ef3;
  --accent-hover: #b7a6f6;
  --accent-soft: #29223f;
  --accent-text: #bcadf8;
  --on-accent: #160f2b;
  --success: #62d18c;
  --success-soft: #183022;
  --warning: #eab45a;
  --info: #8db2f8;
  --info-soft: #1b2540;
  --danger: #f08a8a;
  --danger-hover: #f5a3a3;
  --danger-soft: #3a1d20;
  --focus: #c2b4fa;
  --desk: #0e0d12;
  --ink: #2c2b34;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  --paper-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 36px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ===================================================================== base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md) / var(--lh) var(--font);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img,
svg {
  max-width: 100%;
}
.i {
  flex-shrink: 0;
  vertical-align: -0.2em;
}
a {
  color: var(--accent-text);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover {
  text-decoration-thickness: 2px;
}
h1,
h2,
h3 {
  font-family: var(--font-head);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  font-weight: 750;
  text-wrap: balance;
}
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.num,
output {
  font-variant-numeric: tabular-nums;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  transform: translateY(-200%);
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.skip:focus {
  transform: none;
  box-shadow: var(--shadow-lg);
}
.muted {
  color: var(--text-muted);
}
.center {
  text-align: center;
}
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-4);
}
@media (min-width: 720px) {
  .container {
    padding: 0 var(--space-5);
  }
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0 0 var(--space-2);
  color: var(--accent-text);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===================================================================== buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.btn:active:not(:disabled):not([aria-disabled='true']) {
  transform: scale(0.98);
}
/* default = secondary: surface + border */
.btn,
.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn:hover,
.btn-secondary:hover {
  background: var(--surface-2);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-soft {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}
.btn-soft:hover {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
[data-theme='dark'] .btn-danger {
  color: #1b0d0e;
}
.btn-sm {
  min-height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--fs-sm);
}
@media (max-width: 767px) {
  .btn-sm {
    min-height: 44px;
  }
}
.btn-block {
  width: 100%;
}
.btn:disabled,
.btn.is-disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.icon-btn.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.lock-btn {
  color: var(--text-muted);
}
.lock-mark {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  vertical-align: -2px;
}
.pro-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0;
}
html.is-pro .free-only,
html.is-pro .is-hidden-pro {
  display: none !important;
}
html:not(.is-pro) .pro-only {
  display: none !important;
}

/* ===================================================================== header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
}
.site-nav {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
}
.site-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.site-nav a[aria-current='page'] {
  color: var(--text);
  background: var(--surface-2);
}
.header-cta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.nav-toggle {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.theme-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}
.theme-toggle:active {
  transform: scale(0.94);
}
.theme-toggle .i {
  grid-area: 1 / 1;
  transition: opacity var(--dur) var(--ease), transform var(--dur-slow) var(--ease);
}
.theme-toggle .i-sun,
[data-theme='dark'] .theme-toggle .i-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}
[data-theme='dark'] .theme-toggle .i-sun {
  opacity: 1;
  transform: none;
}
@media (min-width: 860px) {
  .theme-toggle {
    width: 40px;
    height: 40px;
  }
}
.nav-toggle .i-close,
.nav-open .nav-toggle .i-open {
  display: none;
}
.nav-open .nav-toggle .i-close {
  display: block;
}
@media (max-width: 859px) {
  .nav-toggle {
    display: inline-grid;
  }
  .header-cta {
    margin-left: auto;
  }
  .site-nav {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: var(--space-2) var(--space-4) var(--space-5);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .nav-open .site-nav {
    display: flex;
    animation: sheet-in var(--dur) var(--ease);
  }
  .site-nav a {
    min-height: 52px;
    padding: 0 var(--space-3);
    font-size: var(--fs-lg);
    color: var(--text);
    border-radius: var(--radius-sm);
  }
  .site-nav a[aria-current='page'] {
    color: var(--accent-text);
    background: var(--accent-soft);
  }
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ===================================================================== hero */
.hero {
  padding-top: var(--space-5);
  padding-bottom: var(--space-5);
}
@media (min-width: 720px) {
  .hero {
    padding-top: var(--space-6);
  }
}
.hero h1 {
  font-size: var(--fs-h1);
  font-weight: 800;
  margin: var(--space-2) 0 var(--space-3);
  max-width: 22ch;
}
.hero--compact h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem);
}
.hero--center,
.hero.center {
  text-align: center;
}
.hero--center h1,
.hero.center h1,
.hero--center .lede,
.hero.center .lede {
  margin-inline: auto;
}
.lede {
  font-size: var(--fs-lg);
  color: var(--text-muted);
  max-width: 62ch;
  margin: 0 0 var(--space-3);
}
.trust {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.trust .i {
  color: var(--success);
  margin-top: 1px;
}
.crumbs {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.crumbs a {
  color: var(--text-muted);
}

/* ===================================================================== cards & forms */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.field {
  margin: 0 0 var(--space-4);
  min-width: 0;
}
.field label,
.field .label,
.license-form label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}
.field .label {
  margin-bottom: 6px;
}
.opt {
  font-weight: 400;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
input[type='text'],
input[type='email'],
input[type='tel'],
input[type='date'],
input[type='search'],
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md); /* ≥16px prevents iOS zoom */
  font-weight: 400;
  line-height: 1.35;
}
input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--text-muted) 75%, transparent);
}
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23857f96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
textarea {
  resize: vertical;
  line-height: 1.45;
}
input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-muted));
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--accent);
}
input[type='color'] {
  display: block;
  width: 56px;
  height: 44px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  cursor: pointer;
}
.color-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: 6px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-weight: 400;
}
.hint {
  margin: 6px 0 0;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-muted);
}
.grid2,
.grid3 {
  display: grid;
  gap: 0 var(--space-4);
  grid-template-columns: minmax(0, 1fr);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-weight: 500;
  cursor: pointer;
}
.check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}
.affix {
  position: relative;
  display: block;
  margin-top: 6px;
}
.affix input {
  margin: 0;
  padding-right: 36px;
}
.affix .suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
}
.affix--icon .i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.affix--icon input {
  padding-left: 40px;
  padding-right: 12px;
}
.input-pair {
  display: flex;
  gap: var(--space-2);
  margin-top: 6px;
}
.input-pair input,
.input-pair select {
  margin: 0;
}
.input-pair input {
  flex: 1;
  min-width: 0;
}
.input-pair select {
  width: auto;
  flex: 0 0 auto;
}
.input-row {
  display: flex;
  gap: var(--space-2);
  margin-top: 6px;
}
.input-row input {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.chip {
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}
.chip:active {
  transform: scale(0.97);
}
@media (max-width: 767px) {
  .chip {
    min-height: 40px;
  }
}
.callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.callout > .i {
  color: var(--accent-text);
}
.callout p {
  flex: 1 1 240px;
  margin: 0;
}

/* segmented control (2–4 exclusive options) */
.seg {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.seg > button,
.seg > label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.seg > button:hover,
.seg > label:hover {
  color: var(--text);
}
.seg > button[aria-pressed='true'],
.seg > button[aria-selected='true'],
.seg > label:has(input:checked) {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
[data-theme='dark'] .seg > button[aria-pressed='true'],
[data-theme='dark'] .seg > button[aria-selected='true'],
[data-theme='dark'] .seg > label:has(input:checked) {
  background: var(--surface-3);
}
.seg > label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg > label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.seg--field {
  display: flex;
  width: 100%;
}
.seg--field > label {
  flex: 1;
  padding: 0 var(--space-2);
}

/* menus */
.menu {
  position: relative;
}
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: 30;
  min-width: 264px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: pop var(--dur) var(--ease);
  transform-origin: top right;
}
.menu-list > button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
}
.menu-list > button .i {
  color: var(--text-muted);
}
.menu-list > button .lock-mark {
  margin-left: auto;
}
.menu-list > button:hover,
.menu-list > button:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.menu-list hr {
  margin: 6px 0;
  border: 0;
  border-top: 1px solid var(--border);
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

/* ===================================================================== editor */
.tool {
  padding-bottom: var(--space-5);
}
.editor {
  position: relative;
}
.ed-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 0 var(--space-4);
}
.ed-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
}
.ed-status.is-on {
  opacity: 1;
}
.ed-status .i {
  color: var(--success);
}
.ed-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.ed-banner {
  margin: 0 0 var(--space-4);
}
.ed-tabs {
  display: flex;
  width: 100%;
  margin-bottom: var(--space-4);
}
.ed-tabs > button {
  flex: 1;
  min-height: 40px;
}
.ed-grid[data-view='edit'] .ed-preview,
.ed-grid[data-view='preview'] .ed-form {
  display: none;
}
.ed-form {
  container-type: inline-size;
  min-width: 0;
}
@container (min-width: 520px) {
  .grid2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 1023px) {
  .wide-only,
  .ed-status {
    display: none !important;
  }
  .seg--type {
    flex: 1;
  }
  .seg--type > button {
    flex: 1;
    padding: 0 var(--space-2);
  }
  .ed-actions {
    margin-left: auto;
  }
}
@media (min-width: 1024px) {
  .narrow-only {
    display: none !important;
  }
}
@media (max-width: 479px) {
  .menu-btn span {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .menu-btn {
    width: 48px;
    padding: 0;
  }
}

/* form sections: collapsible cards */
.sec {
  margin: 0 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.sec > summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius-lg);
}
.sec > summary::-webkit-details-marker {
  display: none;
}
.sec > summary:hover .sec-chev {
  color: var(--text);
}
.sec-icon {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.sec-icon .i {
  width: 18px;
  height: 18px;
}
.sec-head {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.sec-title {
  font-family: var(--font-head);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.sec-sum {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sec-sum:empty,
.sec[open] .sec-sum {
  display: none;
}
.sec-chev {
  color: var(--text-muted);
  transition: transform var(--dur) var(--ease);
}
.sec[open] .sec-chev {
  transform: rotate(180deg);
}
.sec-body {
  padding: var(--space-1) var(--space-4) var(--space-4);
}
@container (min-width: 520px) {
  .sec > summary {
    padding: var(--space-3) var(--space-5);
  }
  .sec-body {
    padding: var(--space-1) var(--space-5) var(--space-5);
  }
}
.sec-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-3);
}

/* line items */
.items-head {
  display: none;
}
.items-list {
  display: grid;
  gap: var(--space-3);
}
.item-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  grid-template-areas: 'desc desc' 'qty price' 'amount actions';
  align-items: end;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.items[data-tax='perLine'] .item-row {
  grid-template-columns: 76px minmax(0, 1fr) 84px;
  grid-template-areas: 'desc desc desc' 'qty price tax' 'amount amount actions';
}
.item-row label > span {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.item-row input,
.item-row textarea {
  margin-top: 4px;
}
.item-row textarea {
  min-height: 44px;
  resize: none;
  overflow: hidden;
}
.f-desc {
  grid-area: desc;
}
.f-qty {
  grid-area: qty;
}
.f-price {
  grid-area: price;
}
.f-tax {
  grid-area: tax;
}
.items:not([data-tax='perLine']) .f-tax,
.items:not([data-tax='perLine']) .col-tax {
  display: none;
}
.f-amount {
  grid-area: amount;
  align-self: center;
  font-family: var(--font-head);
  font-weight: 700;
  white-space: nowrap;
}
.f-amount::before {
  content: 'Amount ';
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  margin-right: var(--space-1);
}
.item-actions {
  grid-area: actions;
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}
.item-actions .menu-list {
  min-width: 220px;
}
@media (max-width: 767px) {
  .item-actions .icon-btn {
    width: 44px;
    height: 44px;
  }
}
@container (min-width: 560px) {
  .items-head,
  .item-row,
  .items[data-tax='perLine'] .item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px 104px 112px 76px;
    grid-template-areas: 'desc qty price amount actions';
    gap: var(--space-2);
    align-items: start;
  }
  .items[data-tax='perLine'] .items-head,
  .items[data-tax='perLine'] .item-row {
    grid-template-columns: minmax(0, 1fr) 60px 96px 60px 104px 76px;
    grid-template-areas: 'desc qty price tax amount actions';
  }
  .items-head {
    padding: 0 0 var(--space-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .items-head span:nth-child(n + 2):not(:last-child) {
    text-align: right;
  }
  .items-head span:nth-child(2) {
    text-align: left;
  }
  .items-head span:nth-child(3) {
    text-align: left;
  }
  .items-list {
    gap: 0;
  }
  .item-row {
    padding: var(--space-2) 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
  }
  .item-row label > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .item-row input,
  .item-row textarea {
    margin-top: 0;
    min-height: 40px;
    padding: 8px 10px;
  }
  .f-amount {
    align-self: start;
    padding-top: 10px;
    text-align: right;
    font-size: var(--fs-md);
  }
  .f-amount::before {
    content: none;
  }
  .item-actions .icon-btn {
    width: 36px;
    height: 40px;
  }
}
.btn-add {
  width: 100%;
  margin-top: var(--space-3);
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--accent-text);
}
.btn-add:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.items-tools,
.saved-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.saved-row {
  margin: 0 0 var(--space-3);
}
.saved-row:not(:has(> :not([hidden]):not(.pro-only):not(.free-only))):empty {
  display: none;
}
.saved-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.saved-tools select,
.saved-tools input {
  width: auto;
  min-width: 200px;
  margin: 0;
}
.logo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.file-btn {
  position: relative;
}
.file-btn:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.logo-thumb {
  max-height: 44px;
  max-width: 120px;
  object-fit: contain;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
}

/* currency combobox */
.combo {
  position: relative;
}
.combo-box {
  position: relative;
  margin-top: 6px;
}
.combo-box input {
  margin: 0;
  padding-right: 84px;
  text-overflow: ellipsis;
}
.combo-sym {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 44px;
  overflow: hidden;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.combo-toggle {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  width: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.combo-list {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 300px;
  overflow: auto;
  margin: var(--space-1) 0 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}
.combo-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.combo-list li[aria-selected='true'] {
  background: var(--accent-soft);
}
.combo-list li[data-current] .opt-code::after {
  content: ' ✓';
  color: var(--accent-text);
}
.combo-list .opt-code {
  flex: 0 0 3.6em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.combo-list .opt-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combo-list .opt-sym {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.combo-list .combo-empty {
  color: var(--text-muted);
  cursor: default;
}

/* design: templates */
.templates {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.tpl {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2);
  min-width: 96px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.tpl:hover {
  border-color: var(--border-strong);
}
.tpl input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.tpl:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tpl:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.tpl-swatch {
  display: block;
  width: 72px;
  height: 90px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #e5e5e5;
  position: relative;
  overflow: hidden;
}
.tpl-swatch::before,
.tpl-swatch::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 4px;
  border-radius: 2px;
  background: #d6d3d1;
}
.tpl-swatch::before {
  top: 34px;
  box-shadow: 0 10px 0 #e7e5e4, 0 20px 0 #e7e5e4, 0 30px 0 #e7e5e4;
}
.tpl-swatch::after {
  bottom: 8px;
  left: 40px;
  background: #6d28d9;
}
.tpl-simple {
  background: linear-gradient(#6d28d9, #6d28d9) 8px 10px / 26px 6px no-repeat, #fff;
}
.tpl-bold {
  background: linear-gradient(#6d28d9, #6d28d9) 0 0 / 100% 24px no-repeat, #fff;
}
.tpl-minimal {
  background: linear-gradient(#1c1917, #1c1917) 8px 12px / 20px 3px no-repeat, #fff;
}

/* preview */
.ed-preview {
  min-width: 0;
}
.ed-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.ed-preview-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.ed-preview-title .muted {
  margin-left: var(--space-1);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  font-size: var(--fs-xs);
}
.desk {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--desk);
  border: 1px solid var(--border);
}
@media (min-width: 720px) {
  .desk {
    padding: var(--space-5);
  }
}
.paper-stage {
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
}
.paper {
  transform-origin: top left;
  background: #fff;
  box-shadow: var(--paper-shadow);
  min-height: 1123px; /* A4 height at 96dpi */
}
.paper[data-paper-size='Letter'] {
  min-height: 1056px;
}
.ed-preview > .hint {
  margin-top: var(--space-3);
}

/* mobile action dock (hidden when the preview is beside the form) */
.ed-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) calc(-1 * var(--space-4)) 0;
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px rgba(28, 24, 40, 0.06);
}
@media (min-width: 720px) {
  .ed-dock {
    margin-inline: calc(-1 * var(--space-5));
    padding-inline: var(--space-5);
  }
}
.dock-total {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-right: auto;
  line-height: 1.2;
}
.dock-label {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.dock-total strong {
  overflow: hidden;
  font-family: var(--font-head);
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dock-view .i-edit,
.dock-view.is-preview .i-preview {
  display: none;
}
.dock-view.is-preview .i-edit {
  display: block;
}
@media (max-width: 379px) {
  .dl-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
@media (max-width: 419px) {
  .dock-view {
    width: 44px;
    padding: 0;
  }
  .dock-view span {
    display: none;
  }
}
@media (min-width: 1024px) {
  .ed-tabs,
  .ed-dock {
    display: none;
  }
  .ed-grid,
  .ed-grid[data-view] {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
  }
  .ed-grid[data-view] .ed-form,
  .ed-grid[data-view] .ed-preview {
    display: block;
  }
  .ed-preview {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-h) - var(--space-6));
    max-height: calc(100dvh - var(--header-h) - var(--space-6));
  }
  .ed-grid[data-view] .ed-preview {
    display: flex;
  }
  .desk {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: max-content;
  max-width: min(480px, calc(100vw - 32px));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 0.9375rem;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast .i {
  color: #9be3b4;
}
.toast[data-kind='error'] .i {
  color: #ffb4b4;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
[data-theme='dark'] .toast {
  border: 1px solid var(--border-strong);
  color: var(--text);
}
@media (max-width: 1023px) {
  body:has(.ed-dock) .toast {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
}
@media (min-width: 1024px) {
  .toast {
    left: auto;
    right: var(--space-5);
    bottom: var(--space-5);
    transform: translateY(12px);
  }
  .toast.is-visible {
    transform: none;
  }
}

/* ===================================================================== history */
.history {
  margin-top: var(--space-6);
  padding: var(--space-4);
}
@media (min-width: 720px) {
  .history {
    padding: var(--space-5);
  }
}
.history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.history-head h2 {
  margin: 0;
  font-size: var(--fs-xl);
}
.history-tools .saved-tools select {
  min-width: 150px;
}
.history-list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.h-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.h-item.is-current {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.h-icon {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
}
.h-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 180px;
}
.h-num {
  font-weight: 700;
}
.h-client {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.h-meta {
  font-size: var(--fs-sm);
}
.h-amt {
  font-family: var(--font-head);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.h-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}
.h-actions select {
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 0 32px 0 10px;
  font-size: var(--fs-sm);
}
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: capitalize;
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge--sent {
  background: var(--info-soft);
  color: var(--info);
}
.badge--paid {
  background: var(--success-soft);
  color: var(--success);
}
.badge--overdue,
.badge--expired {
  background: var(--danger-soft);
  color: var(--danger);
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-6) var(--space-4) var(--space-4);
  text-align: center;
}
.empty p {
  margin: 0;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
}
.history .empty + .hint:empty {
  display: none;
}

/* ===================================================================== content */
.section-title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-2xl);
  font-weight: 800;
}
.section-lede {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
}
.cats {
  padding-top: var(--space-7);
  padding-bottom: var(--space-4);
}
.cat-title {
  margin: var(--space-5) 0 var(--space-3);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cat-grid,
.related {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.cat-grid li,
.related li {
  margin: 0;
}
.cat-card,
.related-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  height: 100%;
  padding: var(--space-4);
  color: var(--text);
  text-decoration: none;
  transition: transform var(--dur) var(--ease);
}
.cat-card:hover,
.related-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow-sm);
}
.cat-card:active,
.related-card:active {
  transform: scale(0.99);
}
.card-icon {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.cat-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.cat-text span,
.related-card > span:last-child {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.cat-text span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.cat-arrow {
  align-self: center;
  color: var(--text-muted);
  transition: transform var(--dur) var(--ease);
}
.cat-card:hover .cat-arrow {
  color: var(--accent-text);
  transform: translateX(3px);
}
.related-card {
  flex-direction: column;
  gap: var(--space-2);
}

.content-grid {
  display: grid;
  gap: var(--space-6);
  padding-top: var(--space-4);
  padding-bottom: var(--space-7);
}
@media (min-width: 1100px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--space-7);
  }
  .sidebar {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
    align-self: start;
  }
}
.prose {
  max-width: 68ch;
  min-width: 0;
}
.prose--center {
  margin-inline: auto;
  padding-bottom: var(--space-6);
}
.prose.narrow {
  padding-bottom: var(--space-7);
}
.prose h2 {
  font-size: var(--fs-2xl);
  margin: var(--space-7) 0 var(--space-3);
}
.prose > section:first-child > h2,
.prose > h2:first-child {
  margin-top: var(--space-5);
}
.prose h3 {
  font-size: var(--fs-xl);
  margin: var(--space-5) 0 var(--space-2);
}
.prose p,
.prose li {
  font-size: 1.0625rem;
  line-height: 1.65;
}
.prose li {
  margin: var(--space-2) 0;
}
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 44px;
  margin: var(--space-3) 0;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: var(--fs-sm);
}
.faqs {
  margin-top: var(--space-7);
}
.faq {
  border-bottom: 1px solid var(--border);
}
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 56px;
  padding: var(--space-3) 0;
  font-weight: 650;
  font-size: var(--fs-lg);
  list-style: none;
  cursor: pointer;
}
.faq summary::-webkit-details-marker {
  display: none;
}
.faq summary::after {
  content: '';
  flex: 0 0 9px;
  height: 9px;
  margin-right: 6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translateY(-3px);
  transition: transform var(--dur) var(--ease);
}
.faq[open] summary::after {
  transform: rotate(225deg) translate(-2px, -1px);
}
.faq summary:hover {
  color: var(--accent-text);
}
.faq p {
  margin: 0 0 var(--space-4);
  color: var(--text);
}
.promo {
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.promo h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-xl);
}
.promo p {
  margin: 0 0 var(--space-3);
  font-size: 0.9375rem;
  color: var(--text-muted);
}
.promo .price-sm {
  color: var(--text);
  font-family: var(--font-head);
  font-weight: 800;
}
.email-tpl {
  margin: var(--space-3) 0 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.email-body p {
  margin: 0 0 var(--space-3);
}
.legal {
  padding-top: var(--space-6);
  padding-bottom: var(--space-7);
}
.legal h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);
}

/* ===================================================================== pricing */
.plans {
  display: grid;
  gap: var(--space-4);
  max-width: 980px;
  margin: var(--space-2) auto var(--space-7);
}
@media (min-width: 760px) {
  .plans {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
}
.plan {
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
}
@media (min-width: 720px) {
  .plan {
    padding: var(--space-6);
  }
}
.plan h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--fs-xl);
}
.plan--pro {
  border: 2px solid var(--accent);
}
.price {
  margin: var(--space-2) 0 var(--space-2);
  font-family: var(--font-head);
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.price-note {
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: 0;
}
.plan-lede {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
}
.plan .checks {
  flex: 1;
}
.plan-cta {
  margin-top: var(--space-2);
}
.checks {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-5);
}
.checks li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: var(--space-2) 0;
}
.checks li .i {
  margin-top: 3px;
  color: var(--success);
}
.cta {
  margin-bottom: var(--space-3);
}
.license-form,
.license-state {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.license-state p .i {
  color: var(--success);
}
[data-license-msg][data-state='error'] {
  color: var(--danger);
}
[data-license-msg][data-state='ok'] {
  color: var(--success);
}
.section-title:has(+ .table-wrap) {
  max-width: 980px;
  margin: 0 auto var(--space-4);
  text-align: center;
}
.table-wrap {
  max-width: 980px;
  margin: 0 auto var(--space-6);
  overflow-x: auto;
}
table.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.compare th,
.compare td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.compare tbody tr:last-child th,
.compare tbody tr:last-child td {
  border-bottom: 0;
}
.compare tbody th {
  font-weight: 500;
}
.compare td {
  width: 24%;
  color: var(--text-muted);
}
.compare thead th {
  background: var(--surface-2);
  font-size: var(--fs-sm);
  font-weight: 700;
}
@media (max-width: 559px) {
  .compare th,
  .compare td {
    padding: var(--space-3);
  }
  .compare td {
    width: 28%;
  }
}
.yes {
  color: var(--success);
}
.no {
  color: var(--text-muted);
}

/* ===================================================================== dialogs */
.dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: var(--space-6) var(--space-5) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
@media (min-width: 720px) {
  .dialog {
    padding: var(--space-6);
  }
}
.dialog[open] {
  animation: pop var(--dur) var(--ease);
}
.dialog::backdrop {
  background: rgba(15, 12, 25, 0.55);
}
.dialog h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-2xl);
}
.dialog-x {
  position: absolute;
  right: var(--space-2);
  top: var(--space-2);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.dialog-x:hover {
  background: var(--surface-2);
  color: var(--text);
}
.pro-reason {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
}
.dialog--confirm {
  width: min(420px, calc(100vw - 32px));
}
.dialog--confirm p {
  margin: 0 0 var(--space-5);
  color: var(--text-muted);
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  gap: var(--space-2);
}
@media (max-width: 479px) {
  .dialog-actions .btn {
    flex: 1;
  }
}
.dialog--preview {
  width: min(920px, calc(100vw - 16px));
  height: calc(100dvh - 16px);
  max-height: none;
  padding: 0;
  overflow: hidden;
}
.dialog--preview[open] {
  display: flex;
  flex-direction: column;
}
.dialog--preview .pv-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.dialog--preview .pv-head h2 {
  flex: 1;
  margin: 0;
  font-size: var(--fs-lg);
}
.dialog--preview .pv-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-4);
  background: var(--desk);
  overscroll-behavior: contain;
}
.dialog--preview .pv-stage {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
}
.dialog--preview .paper {
  cursor: default;
}

/* ===================================================================== ads */
.ad-slot {
  display: none;
}
html.ads-on .ad-slot {
  display: block;
  margin: var(--space-6) auto;
  width: 100%;
  overflow: hidden;
}
html.ads-on .ad-slot--top {
  min-height: 100px;
}
html.ads-on .ad-slot--inContent {
  min-height: 280px;
}
html.ads-on .ad-slot--sidebar {
  min-height: 600px;
  margin-top: 0;
}
@media (max-width: 1099px) {
  html.ads-on .ad-slot--sidebar {
    display: none;
  }
}
.ad-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: inherit;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}
html.is-pro .ad-slot {
  display: none !important;
}

/* ===================================================================== footer */
.site-footer {
  margin-top: var(--space-7);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9375rem;
}
.footer-grid {
  display: grid;
  gap: var(--space-6) var(--space-5);
  padding-top: var(--space-7);
  padding-bottom: var(--space-6);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 900px) {
  .footer-grid {
    grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
  }
}
.footer-brand {
  grid-column: 1 / -1;
}
@media (min-width: 900px) {
  .footer-brand {
    grid-column: auto;
  }
}
.footer-brand p {
  max-width: 32ch;
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.site-footer h2 {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.site-footer li {
  margin: 0;
}
.site-footer nav a {
  display: inline-block;
  padding: 6px 0;
  color: var(--text);
  text-decoration: none;
}
.site-footer nav a:hover {
  color: var(--accent-text);
  text-decoration: underline;
}
.footer-bottom {
  padding-top: var(--space-4);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.footer-bottom p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* =====================================================================
   THE DOCUMENT (preview + PDF). Always light "paper", independent of theme.
   ===================================================================== */
.doc {
  --pad: 48px;
  --ink: #1c1917;
  --soft: #6b6560;
  --line: #e7e2dc;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: inherit;
  padding: var(--pad) 52px;
  background: #fff;
  color: var(--ink);
  font: 13px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  color-scheme: light;
}
.doc h2,
.doc h3,
.doc p {
  margin: 0;
}
.doc .ph {
  color: #b8b0a8;
  font-weight: 400;
  font-style: italic;
}
.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 32px;
}
.doc-brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.doc-logo {
  max-width: 200px;
  max-height: 72px;
  object-fit: contain;
  object-position: left center;
}
.doc-from {
  color: var(--soft);
  overflow-wrap: anywhere;
}
.doc-from-name {
  color: var(--ink);
  font-size: 15px;
}
.doc-titlebox {
  text-align: right;
  flex-shrink: 0;
}
.doc-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--doc-accent);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.doc-meta {
  margin: 0;
  display: grid;
  gap: 2px;
}
.doc-meta div {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.doc-meta dt {
  color: var(--soft);
}
.doc-meta dd {
  margin: 0;
  font-weight: 600;
  min-width: 90px;
}
.doc-parties {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 26px;
}
.doc h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--soft);
  margin-bottom: 4px;
}
.doc-to p {
  overflow-wrap: anywhere;
}
.doc-stamp {
  transform: rotate(-8deg);
  border: 3px solid #15803d;
  color: #15803d;
  border-radius: 8px;
  padding: 4px 16px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}
.doc-items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}
.doc-items th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--soft);
  font-weight: 700;
  padding: 8px 8px;
  border-bottom: 2px solid var(--doc-accent);
  text-align: left;
}
.doc-items td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.doc-items tr {
  break-inside: avoid;
}
.doc-items th:first-child,
.doc-items td:first-child {
  padding-left: 0;
}
.doc-items th:last-child,
.doc-items td:last-child {
  padding-right: 0;
}
.doc .d-num {
  text-align: right;
  white-space: nowrap;
}
.doc .d-desc {
  width: 100%;
  overflow-wrap: anywhere;
}
.doc-summary {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  break-inside: avoid;
}
.doc-side {
  flex: 1;
  display: grid;
  gap: 14px;
  align-content: start;
  overflow-wrap: anywhere;
}
.doc-totals {
  border-collapse: collapse;
  min-width: 260px;
}
.doc-totals th,
.doc-totals td {
  padding: 5px 0;
  text-align: right;
}
.doc-totals th {
  font-weight: 400;
  color: var(--soft);
  padding-right: 24px;
}
.doc-totals th small {
  font-size: 11px;
}
.doc-totals .d-total th,
.doc-totals .d-total td {
  border-top: 2px solid var(--ink);
  padding-top: 9px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
.doc-totals .d-balance th,
.doc-totals .d-balance td {
  font-weight: 800;
  color: var(--doc-accent);
  font-size: 15px;
}
.doc-terms {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--soft);
  break-inside: avoid;
}
.doc-foot {
  margin-top: auto;
  padding-top: 28px;
  text-align: center;
  font-size: 10px;
  color: #a8a29e;
}

/* Bold: solid accent header band */
.doc--bold .doc-head {
  margin: calc(-1 * var(--pad)) -52px 32px;
  padding: 36px 52px 30px;
  background: var(--doc-accent);
  color: #fff;
}
.doc--bold .doc-from,
.doc--bold .doc-meta dt {
  color: rgba(255, 255, 255, 0.82);
}
.doc--bold .doc-from-name,
.doc--bold .doc-title {
  color: #fff;
}
.doc--bold .ph {
  color: rgba(255, 255, 255, 0.6);
}
.doc--bold .doc-logo {
  background: #fff;
  padding: 6px;
  border-radius: 6px;
}
.doc--bold .doc-items th {
  background: #f5f2ee;
  border-bottom: 0;
  padding-left: 8px;
}
.doc--bold .doc-items th:first-child {
  padding-left: 8px;
}
.doc--bold .doc-items td:first-child {
  padding-left: 8px;
}
.doc--bold .doc-totals .d-total th,
.doc--bold .doc-totals .d-total td {
  border-top: 0;
  background: var(--doc-accent);
  color: #fff;
  padding: 9px 10px;
}

/* Minimal: airy, hairlines, accent only on the total */
.doc--minimal {
  font-weight: 400;
}
.doc--minimal .doc-title {
  color: var(--ink);
  font-weight: 300;
  font-size: 34px;
  text-transform: none;
  letter-spacing: 0;
}
.doc--minimal .doc-head {
  margin-bottom: 44px;
}
.doc--minimal .doc-items th {
  border-bottom: 1px solid var(--ink);
  font-weight: 500;
}
.doc--minimal .doc-items td {
  border-bottom: 0;
  padding-top: 10px;
  padding-bottom: 10px;
}
.doc--minimal .doc-items tbody tr:last-child td {
  border-bottom: 1px solid var(--line);
}
.doc--minimal .doc-totals .d-total th,
.doc--minimal .doc-totals .d-total td {
  border-top: 1px solid var(--ink);
  font-weight: 600;
  color: var(--doc-accent);
  font-size: 18px;
}
.doc--minimal .doc-terms {
  border-top: 0;
}

/* ---------- print: only the document ---------- */
@media screen {
  #print-root {
    display: none;
  }
}
@media print {
  /* Print is always light, whatever the screen theme. */
  :root,
  :root[data-theme='dark'] {
    color-scheme: light !important;
    --bg: #fff;
  }
  html,
  body {
    background: #fff !important;
  }
  body > *:not(#print-root) {
    display: none !important;
  }
  #print-root {
    display: block;
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #print-root .doc {
    --pad: 0px;
    padding: 0;
    min-height: auto;
    display: block;
  }
  #print-root .doc--bold .doc-head {
    margin: 0 0 28px;
    padding: 24px 28px;
    border-radius: 4px;
  }
  #print-root .doc .ph {
    visibility: hidden;
  }
  #print-root .doc-foot {
    padding-top: 36px;
  }
}

/* loading state for buttons (spinner + label) */
.btn[aria-busy='true']::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
