:root {
  --navy: #0c1222;
  --navy-2: #152038;
  --ink: #1a2f4a;
  --muted: #64748b;
  --line: #d7e0ea;
  --paper: #f4f7fb;
  --white: #ffffff;
  --accent: #0891b2;
  --accent-soft: rgba(0, 212, 255, 0.12);
  --cyan: #00d4ff;
  --good: #0f766e;
  --warn: #b45309;
  --bad: #be123c;
  --shadow: 0 18px 50px rgba(12, 18, 34, 0.12);
  --radius: 16px;
  --font: Outfit, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 15px;
}

.hidden { display: none !important; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--navy);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 50;
}
.skip-link:focus { top: 12px; }

.faq-list {
  display: grid;
  gap: 12px;
  max-width: 860px;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(244, 247, 251, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--navy);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  border: 1px solid rgba(0, 212, 255, 0.35);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}

.nav-links a:hover { color: var(--navy); }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  background: var(--navy);
  color: #fff;
}

.btn:hover { background: var(--navy-2); }

.btn.secondary {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--line);
}

.btn.ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
}

.btn.danger { background: var(--bad); }
.btn.small { padding: 7px 12px; font-size: 13px; }

.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 72px 24px 40px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}

.kicker {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
  margin-bottom: 12px;
}

h1 {
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.05;
  color: var(--navy);
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.lede {
  font-size: 18px;
  color: var(--muted);
  max-width: 540px;
  margin-bottom: 28px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.hero-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.hero-card .doc-preview h2 {
  font-size: 22px;
  color: var(--navy);
}

.preview-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0;
}

.preview-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 13px;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  text-align: left;
}

.preview-table td:last-child,
.preview-table th:last-child { text-align: right; }

.section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.section h2 {
  color: var(--navy);
  font-size: 28px;
  margin-bottom: 8px;
}

.section p.sub {
  color: var(--muted);
  margin-bottom: 24px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.card h3 { color: var(--navy); margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 14px; }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.step-num {
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}

.privacy-banner {
  background: var(--navy);
  color: #dbeafe;
  border-radius: 20px;
  padding: 28px;
}

.privacy-banner h2 { color: #fff; }
.privacy-banner p { margin-top: 8px; color: #94a3b8; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  max-width: 1100px;
  margin: 0 auto;
}

.site-footer a { color: var(--navy); font-weight: 600; text-decoration: none; }

.auth-shell {
  min-height: calc(100vh - 128px);
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-card h1 { font-size: 34px; }
.auth-card form { margin-top: 22px; }
.auth-card form label { margin-top: 14px; }
.auth-submit { width: 100%; margin-top: 8px; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--muted); }

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.form-message { min-height: 24px; margin: 10px 0 2px; color: var(--bad); font-size: 14px; }
.form-message.success { color: var(--good); }

.consent-field { margin-top: 16px; }
.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.consent-label input {
  margin-top: 3px;
  width: auto;
  flex: 0 0 auto;
}

.sidebar-account {
  margin: 0 10px 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.sidebar-account span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  color: var(--navy);
}

.workspace {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 63px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 18px 14px;
}

.sidebar h2 {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 10px 10px;
}

.biz-switch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 4px 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.biz-switch select {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 650;
}

.business-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.business-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 650;
}

.business-tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.business-choice-list {
  display: grid;
  gap: 12px;
  max-width: 720px;
}

.business-choice {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
}

.business-choice:hover,
.business-choice.active {
  border-color: var(--navy);
}

.business-choice img,
.business-choice-mark {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--paper);
}

.business-choice-mark {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--navy);
}

.side-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 650;
  color: var(--ink);
}

.side-btn:hover, .side-btn.active { background: var(--paper); color: var(--navy); }

.pane-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 13px 16px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
}

.pane-toggle::after { content: "▾"; color: var(--muted); }
.pane-toggle[aria-expanded="true"]::after { content: "▴"; }

.main-pane { padding: 24px; }

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.search {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  min-width: 220px;
  background: #fff;
}

.doc-list { display: grid; gap: 10px; }

.doc-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr 0.7fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}

.doc-row:hover { border-color: #94a3b8; }
.doc-row strong { color: var(--navy); }
.doc-row .muted { color: var(--muted); font-size: 13px; }

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #e2e8f0;
  color: var(--navy);
  text-transform: capitalize;
}

.badge.quote { background: #e0f2fe; color: #075985; }
.badge.invoice { background: #dcfce7; color: #166534; }
.badge.credit_note { background: #fef3c7; color: #92400e; }
.badge.receipt { background: #ede9fe; color: #5b21b6; }
.badge.paid { background: #d1fae5; color: var(--good); }
.badge.draft { background: #e2e8f0; }
.badge.sent { background: #dbeafe; color: #1d4ed8; }
.badge.overdue { background: #ffe4e6; color: var(--bad); }

.empty {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.editor {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.panel h2 { font-size: 16px; color: var(--navy); margin-bottom: 14px; }

.grid-2, .grid-3 {
  display: grid;
  gap: 12px;
}

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: #fff;
  color: var(--navy);
}

textarea { min-height: 90px; resize: vertical; }

.line-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.line-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 4px; }
.line-table td { padding: 4px; vertical-align: top; }
.line-table input { padding: 8px; }
.line-table .qty { width: 72px; }
.line-table .money { width: 110px; }
.totals { margin-top: 12px; text-align: right; color: var(--navy); }
.totals .grand { font-size: 22px; font-weight: 800; }

.print-page {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  min-height: 640px;
}

.letterhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 3px solid var(--navy);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.letterhead .logo { font-size: 22px; font-weight: 800; color: var(--navy); }
.letterhead .tag { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

.document-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.document-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 8px;
}

.logo-uploader {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.logo-preview {
  width: 86px;
  height: 86px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}

.brand-controls { margin-bottom: 8px; }
.brand-controls small, .optional { color: var(--muted); font-weight: 400; }
.editor-logo-control input { padding: 8px; }
.editor-logo-preview {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.editor-logo-preview img {
  width: 62px;
  height: 62px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}
.profile-link { margin: 8px 0 14px; font-size: 14px; }
.panel-divider { border: 0; border-top: 1px solid var(--line); margin: 0 0 18px; }

.email-box {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.email-box h2 { margin-bottom: 10px; }



.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.doc-head h1 { font-size: 28px; margin: 0; }
.meta { text-align: right; color: var(--muted); font-size: 13px; }
.meta strong { color: var(--navy); }

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.party-label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.party-name { font-weight: 800; color: var(--navy); }

.print-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 16px; }
.print-table th, .print-table td { border: 1px solid #94a3b8; padding: 8px 10px; }
.print-table th { background: #e8eef4; color: var(--navy); text-transform: uppercase; font-size: 11px; }
.amount { text-align: right; white-space: nowrap; }
.total-row { font-weight: 800; background: #f0f9ff; }

.bank-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-left: 4px solid var(--navy);
  padding: 12px 14px;
  margin: 8px 0 16px;
  font-size: 13px;
}

.theme-field { margin: 4px 0 16px; max-width: 420px; }

.guest-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 4px solid #ea580c;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  color: #9a3412;
  font-size: 14px;
}

.save-indicator { font-size: 13px; color: var(--muted); align-self: center; }
.save-indicator.error { color: var(--bad); }

/* Printable document themes */
.print-page { --doc-accent: var(--navy); --doc-soft: #e8eef4; --doc-total: #f0f9ff; }
.print-page .letterhead { border-color: var(--doc-accent); }
.print-page .letterhead .logo,
.print-page .doc-head h1,
.print-page .meta strong,
.print-page .party-name { color: var(--doc-accent); }
.print-page .print-table th { background: var(--doc-soft); color: var(--doc-accent); }
.print-page .total-row { background: var(--doc-total); }
.print-page .bank-box { border-left-color: var(--doc-accent); }

.theme-modern {
  --doc-accent: #2563eb;
  --doc-soft: #dbeafe;
  --doc-total: #eff6ff;
  border-top: 10px solid #2563eb;
}
.theme-modern .letterhead { border-bottom-width: 1px; }
.theme-modern .doc-head h1 {
  background: #2563eb;
  color: #fff;
  padding: 7px 14px;
  border-radius: 6px;
  letter-spacing: .04em;
}
.theme-modern .print-table th, .theme-modern .print-table td { border-color: #bfdbfe; }

.theme-elegant {
  --doc-accent: #6b4f3a;
  --doc-soft: #f2ebe3;
  --doc-total: #faf7f2;
  font-family: Georgia, "Times New Roman", serif;
  border-color: #c9b8a7;
}
.theme-elegant .letterhead { border-bottom: 1px solid #6b4f3a; }
.theme-elegant .letterhead .logo { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
.theme-elegant .doc-head h1 { font-weight: 500; letter-spacing: .12em; }
.theme-elegant .print-table th { letter-spacing: .08em; }
.theme-elegant .print-table th, .theme-elegant .print-table td { border-color: #c9b8a7; }

.theme-minimal {
  --doc-accent: #111827;
  --doc-soft: #fff;
  --doc-total: #f9fafb;
  border: 0;
  border-radius: 0;
}
.theme-minimal .letterhead { border-bottom: 1px solid #111827; }
.theme-minimal .print-table th,
.theme-minimal .print-table td {
  border-width: 0 0 1px;
  border-color: #d1d5db;
}
.theme-minimal .print-table th { text-align: left; }
.theme-minimal .bank-box { background: #fff; border-width: 1px 0; border-color: #d1d5db; }

.theme-forest {
  --doc-accent: #166534;
  --doc-soft: #dcfce7;
  --doc-total: #f0fdf4;
  border-top: 8px solid #166534;
}
.theme-forest .print-table th, .theme-forest .print-table td { border-color: #86efac; }
.theme-forest .bank-box { background: #f0fdf4; border-color: #bbf7d0; }

.theme-coral {
  --doc-accent: #9a3412;
  --doc-soft: #ffedd5;
  --doc-total: #fff7ed;
  border-top: 8px solid #ea580c;
}
.theme-coral .letterhead { border-bottom-width: 2px; }
.theme-coral .print-table th, .theme-coral .print-table td { border-color: #fdba74; }
.theme-coral .bank-box { background: #fff7ed; border-color: #fed7aa; }

.theme-midnight {
  --doc-accent: #e2e8f0;
  --doc-soft: #1e293b;
  --doc-total: #0f172a;
  background: #fff;
  border: 1px solid #0f172a;
}
.theme-midnight .letterhead {
  background: #0f172a;
  color: #e2e8f0;
  border-bottom: 0;
  margin: -28px -28px 18px;
  padding: 22px 28px 16px;
  border-radius: 8px 8px 0 0;
}
.theme-midnight .letterhead .logo,
.theme-midnight .letterhead .tag,
.theme-midnight .doc-head h1,
.theme-midnight .meta strong,
.theme-midnight .party-name { color: #0f172a; }
.theme-midnight .letterhead .logo,
.theme-midnight .letterhead .tag { color: #f8fafc; }
.theme-midnight .doc-head h1 { color: #0f172a; }
.theme-midnight .print-table th { background: #0f172a; color: #f8fafc; }
.theme-midnight .total-row { background: #e2e8f0; color: #0f172a; }
.theme-midnight .bank-box { background: #0f172a; color: #e2e8f0; border-color: #0f172a; }

.theme-slate {
  --doc-accent: #0f766e;
  --doc-soft: #ccfbf1;
  --doc-total: #f0fdfa;
  border-left: 8px solid #0f766e;
}
.theme-slate .letterhead { border-bottom: 2px solid #0f766e; }
.theme-slate .print-table th, .theme-slate .print-table td { border-color: #99f6e4; }
.theme-slate .bank-box { background: #f0fdfa; border-color: #99f6e4; }

.theme-noir {
  --doc-accent: #0a0a0a;
  --doc-soft: #fff;
  --doc-total: #0a0a0a;
  border: 1px solid #0a0a0a;
  padding: 34px;
}
.theme-noir .letterhead { border-bottom: 1px solid #0a0a0a; padding-bottom: 18px; }
.theme-noir .letterhead .logo {
  font-weight: 400;
  letter-spacing: .28em;
  text-transform: uppercase;
  font-size: 18px;
}
.theme-noir .doc-head h1 {
  font-weight: 300;
  letter-spacing: .34em;
  font-size: 22px;
}
.theme-noir .party-label { letter-spacing: .22em; }
.theme-noir .print-table th {
  background: #fff;
  border-width: 0 0 1px;
  border-color: #0a0a0a;
  letter-spacing: .18em;
  font-weight: 600;
}
.theme-noir .print-table td { border-width: 0 0 1px; border-color: #e5e5e5; }
.theme-noir .total-row { background: #0a0a0a; color: #fff; }
.theme-noir .total-row td { border-color: #0a0a0a; }
.theme-noir .bank-box { background: #fff; border: 1px solid #0a0a0a; border-left-width: 1px; }

.theme-ledger {
  --doc-accent: #1e3a5f;
  --doc-soft: #eef2f7;
  --doc-total: #dde7f3;
  border-color: #c3d0e0;
}
.theme-ledger .letterhead { border-bottom: 2px double #1e3a5f; }
.theme-ledger .meta, .theme-ledger .amount, .theme-ledger .totals {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.theme-ledger .print-table { font-size: 12.5px; }
.theme-ledger .print-table th {
  border-width: 1px 0;
  border-color: #1e3a5f;
  letter-spacing: .1em;
}
.theme-ledger .print-table td { border-width: 0 0 1px; border-color: #d4dce8; }
.theme-ledger .print-table tbody tr:nth-child(even) td { background: #f7f9fc; }
.theme-ledger .total-row { border-top: 2px double #1e3a5f; }
.theme-ledger .bank-box { background: #f7f9fc; border-color: #c3d0e0; }

.theme-aurora {
  --doc-accent: #4c1d95;
  --doc-soft: #ede9fe;
  --doc-total: #f5f3ff;
  border: 0;
  box-shadow: 0 0 0 1px #e9d5ff;
}
.theme-aurora .letterhead {
  background: linear-gradient(110deg, #4338ca, #7c3aed 55%, #c026d3);
  margin: -28px -28px 22px;
  padding: 26px 28px 20px;
  border: 0;
  border-radius: 8px 8px 0 0;
}
.theme-aurora .letterhead .logo, .theme-aurora .letterhead .tag { color: #fff; }
.theme-aurora .letterhead .muted { color: rgba(255, 255, 255, .82); }
.theme-aurora .doc-head h1 { font-weight: 800; }
.theme-aurora .print-table th { border-color: #ddd6fe; }
.theme-aurora .print-table td { border-color: #ede9fe; }
.theme-aurora .bank-box { background: #f5f3ff; border-color: #ddd6fe; }

.theme-sandstone {
  --doc-accent: #7c5c34;
  --doc-soft: #f1e7d8;
  --doc-total: #faf5ec;
  font-family: "Iowan Old Style", Georgia, serif;
  background: #fffdf8;
  border-color: #e2d3bb;
}
.theme-sandstone .letterhead {
  border-bottom: 1px solid #c9b391;
  align-items: flex-start;
}
.theme-sandstone .letterhead .logo {
  font-family: inherit;
  font-weight: 600;
  font-size: 25px;
}
.theme-sandstone .doc-head h1 {
  font-family: inherit;
  font-weight: 400;
  font-style: italic;
  letter-spacing: .04em;
}
.theme-sandstone .print-table th {
  background: #f1e7d8;
  border-color: #dfcdb0;
  font-variant: small-caps;
  text-transform: none;
  letter-spacing: .06em;
  font-size: 12px;
}
.theme-sandstone .print-table td { border-color: #e6d9c2; }
.theme-sandstone .bank-box { background: #faf5ec; border-color: #dfcdb0; }

.theme-plum {
  --doc-accent: #6b1839;
  --doc-soft: #f6e6ec;
  --doc-total: #fdf4f7;
  border-color: #e4c3d1;
}
.theme-plum .letterhead {
  border-bottom: 3px solid #6b1839;
  position: relative;
}
.theme-plum .letterhead .tag { color: #9d2f5a; }
.theme-plum .doc-head h1 {
  border-left: 5px solid #9d2f5a;
  padding-left: 12px;
  letter-spacing: .08em;
}
.theme-plum .print-table th { border-color: #e4c3d1; letter-spacing: .1em; }
.theme-plum .print-table td { border-color: #f0dbe3; }
.theme-plum .bank-box { background: #fdf4f7; border-color: #e4c3d1; }

.theme-nordic {
  --doc-accent: #37506b;
  --doc-soft: #eff3f7;
  --doc-total: #f7fafc;
  border-color: #dde5ec;
  padding: 38px;
  line-height: 1.7;
}
.theme-nordic .letterhead {
  display: block;
  border-bottom: 1px solid #dde5ec;
  padding-bottom: 20px;
  margin-bottom: 26px;
}
.theme-nordic .letterhead .tag { display: block; margin-top: 10px; letter-spacing: .24em; }
.theme-nordic .letterhead .logo { font-weight: 600; letter-spacing: .02em; }
.theme-nordic .doc-head h1 { font-weight: 500; letter-spacing: .2em; font-size: 24px; }
.theme-nordic .party-label { letter-spacing: .18em; }
.theme-nordic .print-table th {
  background: transparent;
  border-width: 0 0 1px;
  border-color: #37506b;
  letter-spacing: .14em;
}
.theme-nordic .print-table td { border-width: 0 0 1px; border-color: #e8eef3; padding: 11px 10px; }
.theme-nordic .bank-box { background: #f7fafc; border-color: #dde5ec; }

.legal {
  max-width: 760px;
  margin: 40px auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
}

.legal h1 { font-size: 32px; }
.legal p, .legal li { color: var(--muted); margin: 10px 0; }
.legal ul { padding-left: 18px; }

@media (max-width: 980px) {
  .hero, .cards, .steps, .editor, .workspace, .doc-row, .grid-2, .grid-3, .parties {
    grid-template-columns: 1fr;
  }
  .workspace { display: block; min-height: 0; }
  .pane-toggle { display: flex; }
  .sidebar {
    display: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px 16px;
  }
  .sidebar.open { display: block; }
  .side-btn { width: 100%; }
  .main-pane { padding: 16px 14px 32px; }
  .hero { padding: 32px 18px 24px; gap: 28px; }
  .section { padding: 24px 18px 48px; }
}

@media (max-width: 720px) {
  html, body { max-width: 100%; overflow-x: hidden; }

  /* Grid and flex children default to min-width:auto, which lets wide
     content (tables, long emails) stretch the page past the screen. */
  .workspace, .main-pane, .editor, .panel, .doc-row, .grid-2, .grid-3,
  .parties, .toolbar-row, .filters, .print-page, .hero, .cards, .steps,
  .editor > *, .main-pane > *, .doc-row > *, .grid-2 > *, .grid-3 > *,
  .parties > *, .toolbar-row > *, .hero > * {
    min-width: 0;
    max-width: 100%;
  }
  img, svg, video { max-width: 100%; height: auto; }
  .card, .panel, .legal, .empty, .doc-row, .print-page, .bank-box, .guest-warning {
    overflow-wrap: anywhere;
  }

  .print-page { overflow-x: auto; }
  .print-table { table-layout: fixed; }
  .print-table th, .print-table td { overflow-wrap: anywhere; }
  .print-table th:first-child, .print-table td:first-child { width: 26px; }
  .amount { white-space: normal; }

  .site-nav { padding: 10px 14px; gap: 8px; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: 12px 10px;
    border-radius: 10px;
    font-size: 15px;
    white-space: nowrap;
  }
  .nav-links a:hover { background: var(--paper); }
  .nav-links .btn { margin-top: 6px; justify-content: center; }

  h1 { font-size: clamp(28px, 8vw, 38px); }
  .lede { font-size: 16px; }
  .section h2 { font-size: 23px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 160px; }
  .hero-card { padding: 16px; }

  /* 16px keeps iOS from zooming when a field gets focus. */
  input, select, textarea, button { font-size: 16px; }
  .btn.small, .nav-links a { font-size: 14px; }

  .auth-shell { min-height: 0; padding: 24px 14px 40px; }
  .auth-card { padding: 22px 18px; border-radius: 16px; }
  .auth-card h1 { font-size: 27px; }

  .toolbar-row { flex-direction: column; align-items: stretch; }
  .toolbar-row h1 { font-size: 24px !important; }
  .filters { width: 100%; }
  .filters .btn, .filters select, .filters .search { flex: 1 1 140px; }
  .search { min-width: 0; width: 100%; }

  .doc-row { gap: 6px; }
  .doc-row > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

  .panel { padding: 14px; }
  .theme-field { max-width: none; }
  .logo-uploader { flex-direction: column; align-items: flex-start; gap: 12px; }
  .business-choice { grid-template-columns: 46px 1fr; }
  .business-choice > :last-child { grid-column: 1 / -1; }

  .line-table thead { display: none; }
  .line-table, .line-table tbody, .line-table tr, .line-table td { display: block; width: 100%; }
  .line-table tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
  }
  .line-table td { padding: 4px 0; }
  .line-table .qty, .line-table .money { width: 100%; }
  .line-table .remove { width: 100%; }

  .print-page { padding: 18px 16px; min-height: 0; }
  .letterhead { flex-direction: column; align-items: flex-start; gap: 8px; }
  .letterhead .logo { font-size: 19px; }
  .doc-head { flex-direction: column; gap: 8px; }
  .doc-head h1 { font-size: 23px; }
  .meta { text-align: left; }
  .print-table { font-size: 12px; }
  .print-table th, .print-table td { padding: 6px 7px; }
  .totals .grand { font-size: 20px; }

  .privacy-banner { padding: 20px; }
  .legal { margin: 20px 14px; padding: 22px 18px; }
  .legal h1 { font-size: 26px; }
  .site-footer { flex-direction: column; gap: 6px; padding: 20px 16px; }
}

@media (max-width: 430px) {
  .site-nav { padding: 8px 12px; }
  .brand { font-size: 15px; }
  .brand-mark { width: 28px; height: 28px; font-size: 13px; }
  .hero { padding: 24px 14px 20px; gap: 22px; }
  .section { padding: 20px 14px 36px; }
  h1 { font-size: 26px; }
  .section h2 { font-size: 21px; }
  .lede { font-size: 15px; }
  .card, .panel, .hero-card { padding: 14px; }
  .main-pane { padding: 12px 10px 28px; }
  .sidebar { padding: 8px 10px; }
  .auth-card { padding: 18px 14px; }
  .print-page { padding: 14px 12px; }
  .print-table { font-size: 11px; }
  .print-table th, .print-table td { padding: 5px; }
  .doc-head h1 { font-size: 20px; }
  .filters .btn, .filters select, .filters .search { flex: 1 1 100%; }
  .hero-actions .btn { flex: 1 1 100%; }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  .site-nav, .sidebar, .toolbar-row, .panel, .site-footer, .no-print, .guest-warning { display: none !important; }
  html, body { background: #fff; margin: 0; }
  .workspace, .main-pane, .editor { display: block; padding: 0; margin: 0; }
  .print-page {
    border: none !important;
    box-shadow: none !important;
    padding: 18mm 16mm;
    min-height: auto;
  }
}
