:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #687387;
  --line: #d9dfeb;
  --paper: #ffffff;
  --field: #f6f8fb;
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --accent: #d97706;
  --blue: #315c9f;
  --bg: #eef3f7;
  --shadow: 0 18px 45px rgba(20, 32, 52, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(217, 119, 6, 0.12), transparent 30%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 14px clamp(18px, 4vw, 52px);
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid rgba(217, 223, 235, 0.8);
  backdrop-filter: blur(18px);
}

.brand,
.nav a {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
}

.brand-mark,
.brand-logo {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.brand-mark {
  color: #fff;
  background: var(--brand);
  font-weight: 900;
}

.brand-logo {
  object-fit: contain;
}

.doc-logo {
  display: inline-grid;
  place-items: center;
  width: 78px;
  height: 52px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 35%),
    linear-gradient(135deg, var(--brand), #1f2937);
  border-radius: 8px;
  font-weight: 900;
  overflow: hidden;
}

.doc-logo svg {
  width: 62px;
  height: 38px;
}

.doc-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(260px, 0.72fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  width: min(1180px, calc(100% - 36px));
  min-height: calc(100vh - 116px);
  margin: 0 auto;
  padding: 48px 0;
}

.hero-copy {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.7;
}

.hero-mark {
  display: grid;
  place-items: center;
  min-height: 360px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 45%),
    rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-mark img {
  width: min(280px, 72%);
}

.tool-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.tool-card {
  min-height: 240px;
  padding: 22px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(20, 32, 52, 0.06);
}

.tool-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.tool-card span {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 18px;
  color: #fff;
  background: var(--brand);
  border-radius: 8px;
  font-weight: 900;
}

.tool-card h2 {
  font-size: 1.25rem;
}

.page-tool {
  min-height: calc(100vh - 160px);
}

.template-page {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0;
}

.template-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(300px, 1.05fr);
  gap: 24px;
  align-items: start;
  margin-top: 26px;
}

.template-copy,
.template-preview,
.profession-card {
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(20, 32, 52, 0.06);
}

.template-copy ul,
.profession-card ul {
  margin: 0 0 22px;
  padding-left: 22px;
  color: #344054;
  line-height: 1.7;
}

.profession-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.profession-card a {
  color: var(--brand-dark);
  font-weight: 800;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.94rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1.06fr) minmax(320px, 0.94fr);
  gap: 22px;
  width: min(1480px, calc(100% - 36px));
  margin: 24px auto 42px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 223, 235, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor {
  padding: clamp(18px, 3vw, 30px);
}

.panel-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 3.2vw, 4rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.editor .panel-head h1 {
  font-size: clamp(1.85rem, 2.5vw, 3.05rem);
  line-height: 1.08;
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 2vw, 2.2rem);
  line-height: 1.12;
}

h3 {
  margin: 0 0 8px;
}

.mode-tabs,
.actions,
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-tabs {
  padding: 4px;
  background: #e8edf4;
  border-radius: 8px;
}

.mode,
.ghost,
.primary,
.secondary,
.link-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.mode {
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
}

.mode.is-active {
  color: #fff;
  background: var(--brand);
}

.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.88rem;
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input[type="color"] {
  padding: 4px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.section-title {
  justify-content: space-between;
  margin: 10px 0 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 1.1rem;
}

.item-row,
.page-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 86px 110px 40px;
  gap: 10px;
  margin-bottom: 10px;
  align-items: end;
}

.page-row {
  grid-template-columns: minmax(120px, 0.5fr) minmax(180px, 1fr) 40px;
}

.remove {
  width: 40px;
  height: 44px;
  border: 1px solid #f0b4a8;
  border-radius: 8px;
  background: #fff4f1;
  color: #a33b25;
  cursor: pointer;
  font-weight: 900;
}

.ghost,
.secondary,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  text-decoration: none;
}

.primary {
  padding: 0 18px;
  background: var(--brand);
  color: #fff;
}

.primary:hover,
.mode.is-active:hover {
  background: var(--brand-dark);
}

.preview-wrap {
  position: sticky;
  top: 88px;
  padding: 14px;
  max-height: calc(100vh - 104px);
  overflow: auto;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
}

.document {
  min-height: 760px;
  padding: clamp(20px, 3vw, 34px);
  margin-bottom: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.document.extra-page {
  min-height: 560px;
}

.copy-label {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-top,
.doc-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
}

.doc-top {
  align-items: start;
  padding-bottom: 26px;
  border-bottom: 4px solid var(--brand);
}

.doc-top h2 {
  margin-top: 12px;
  margin-bottom: 4px;
}

.doc-top p,
.doc-grid p,
.doc-notes,
.template-grid p,
.content p,
footer,
.muted {
  color: var(--muted);
  line-height: 1.6;
}

.doc-meta {
  display: grid;
  gap: 6px;
  justify-items: end;
  text-align: right;
}

.doc-meta strong {
  font-size: 1.45rem;
  color: var(--brand);
}

.doc-grid {
  grid-template-columns: 1.4fr 1fr 1fr;
  margin: 26px 0;
}

small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th {
  color: #fff;
  background: var(--ink);
  text-align: left;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

th:not(:first-child),
td:not(:first-child) {
  text-align: right;
}

.totals {
  width: min(320px, 100%);
  margin: 24px 0 0 auto;
}

.totals p {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.totals .grand {
  color: #fff;
  background: var(--brand);
  margin-top: 10px;
  padding: 14px;
  border-radius: 8px;
  border: 0;
  font-size: 1.1rem;
}

.doc-notes,
.signature-area,
.payment-box {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.signature-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: end;
}

.signature-line {
  min-height: 82px;
  display: grid;
  align-items: end;
  border-bottom: 2px solid var(--ink);
}

.signature-line img {
  max-height: 78px;
  max-width: 100%;
  object-fit: contain;
}

.band,
.tools-band {
  background: rgba(255, 255, 255, 0.74);
  border-block: 1px solid rgba(217, 223, 235, 0.82);
}

.tools-band {
  background: rgba(247, 250, 252, 0.86);
}

.content {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 1.1fr);
  gap: 28px;
  align-items: start;
}

.tool-output,
.contract-preview,
.business-card,
.image-canvas {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.qr-box {
  min-height: 280px;
  display: grid;
  place-items: center;
  padding: 28px;
}

.qr-box img {
  width: min(260px, 100%);
  height: auto;
}

.business-card {
  min-height: 230px;
  padding: 28px;
  display: grid;
  align-content: end;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #1f2937);
}

.business-card strong {
  font-size: 2rem;
}

.business-card span,
.business-card p {
  margin: 4px 0;
  color: rgba(255, 255, 255, 0.86);
}

.contract-preview {
  padding: 24px;
  line-height: 1.65;
}

.contract-body {
  background: #fff;
}

.contract-cover,
.contract-back-cover {
  min-height: 760px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 24px;
  padding: clamp(28px, 4vw, 54px);
  margin: -24px -24px 28px;
  color: #18212f;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.cover-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
}

.cover-brand img {
  width: 58px;
  height: 44px;
  object-fit: contain;
}

.cover-main {
  align-self: center;
}

.back-cover-main {
  align-self: center;
}

.cover-main p,
.back-cover-main p {
  margin: 0 0 14px;
  color: var(--cover-accent);
  font-weight: 900;
  text-transform: uppercase;
}

.cover-main h1,
.back-cover-main h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 5.6rem);
  line-height: 0.98;
}

.cover-main h2,
.back-cover-main h2 {
  max-width: 640px;
  margin-top: 18px;
  color: #475467;
  font-size: clamp(1rem, 1.6vw, 1.45rem);
}

.cover-summary {
  max-width: 720px;
  color: #475467;
  font-size: 1.02rem;
}

.cover-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.cover-meta div {
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(217, 223, 235, 0.9);
  border-radius: 8px;
}

.cover-meta strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.cover-executive {
  color: #fff;
  background:
    linear-gradient(135deg, var(--cover-accent), #111827 72%),
    #111827;
}

.cover-executive .cover-main p,
.cover-executive .cover-main h2,
.cover-executive .back-cover-main p,
.cover-executive .back-cover-main h2,
.cover-executive .cover-summary {
  color: rgba(255, 255, 255, 0.78);
}

.cover-executive .cover-meta div {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

.cover-modern {
  background:
    linear-gradient(90deg, var(--cover-accent) 0 18px, transparent 18px),
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), transparent 44%),
    #fff;
}

.cover-formal {
  border: 12px double var(--cover-accent);
  background: #fff;
}

.cover-formal .cover-main,
.cover-formal .back-cover-main {
  text-align: center;
}

.cover-formal .cover-main h1,
.cover-formal .cover-main h2,
.cover-formal .back-cover-main h1,
.cover-formal .back-cover-main h2,
.cover-formal .cover-summary {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.cover-minimal {
  min-height: 620px;
  background:
    linear-gradient(180deg, transparent 0 74%, rgba(15, 118, 110, 0.14) 74%),
    #fff;
}

.contract-preview h1 {
  font-size: clamp(1.5rem, 2vw, 2.1rem);
}

.contract-preview h2 {
  margin-top: 24px;
  font-size: 1.08rem;
}

.contract-preview ul {
  padding-left: 22px;
}

.contract-preview-wrap {
  position: sticky;
  top: 88px;
  padding: 14px;
  max-height: calc(100vh - 104px);
  overflow: auto;
}

.contract-tool-grid {
  grid-template-columns: minmax(320px, 0.94fr) minmax(340px, 1.06fr);
}

.contract-options {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.custom-sections {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.custom-section-row {
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.custom-remove {
  align-self: end;
  justify-self: end;
}

.contract-options label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contract-options input {
  width: 18px;
  min-height: 18px;
}

.contract-signatures p {
  margin: 8px 0 0;
  color: var(--muted);
}

.contract-note {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.invoice-sample {
  overflow: hidden;
}

.sample-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--brand);
}

.sample-top img {
  width: 72px;
  height: 54px;
  object-fit: contain;
}

.sample-top div {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.sample-top strong {
  color: var(--brand);
  font-size: 1.25rem;
}

.sample-top span,
.sample-parties,
.sample-total span {
  color: var(--muted);
}

.sample-parties {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0;
  font-weight: 800;
}

.sample-total {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 14px;
  color: #fff;
  background: var(--brand);
  border-radius: 8px;
}

.sample-total span {
  color: rgba(255, 255, 255, 0.84);
}

.image-canvas {
  width: 100%;
  min-height: 260px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.template-grid article {
  min-height: 148px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.legal p {
  max-width: 920px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

footer span:first-child {
  color: var(--ink);
  font-weight: 900;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 750;
}

.trust-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(260px, 0.42fr);
  gap: 24px;
  align-items: start;
  margin-top: 28px;
}

.trust-layout article,
.trust-aside,
.policy-copy {
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(20, 32, 52, 0.06);
}

.trust-page h2,
.policy-copy h2 {
  margin-top: 24px;
  font-size: 1.15rem;
}

.trust-page h2:first-child,
.policy-copy h2:first-child {
  margin-top: 0;
}

@media (max-width: 980px) {
  .workspace,
  .tool-grid,
  .template-layout,
  .trust-layout,
  .home-hero {
    grid-template-columns: 1fr;
  }

  .preview-wrap {
    position: static;
    max-height: none;
  }

  .panel-head {
    grid-template-columns: 1fr;
  }

  .template-grid,
  .tool-cards,
  .profession-grid {
    grid-template-columns: 1fr;
  }

  .cover-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  .two,
  .three,
  .doc-grid,
  .signature-area {
    grid-template-columns: 1fr;
  }

  .item-row,
  .page-row {
    grid-template-columns: 1fr 1fr;
  }

  .item-row label:first-child,
  .page-row label:nth-child(2) {
    grid-column: 1 / -1;
  }

  .remove {
    width: 100%;
  }

  .cover-meta {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  .topbar,
  .editor,
  .preview-toolbar,
  .band,
  .tools-band,
  .content:not(#printOnly),
  footer {
    display: none !important;
  }

  .workspace,
  .preview-wrap,
  #printStack {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    max-height: none;
    overflow: visible;
  }

  .document {
    width: 100%;
    min-height: 260mm;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .contract-cover,
  .contract-back-cover {
    min-height: 260mm;
    margin: 0;
  }

  .contract-cover {
    break-after: page;
    page-break-after: always;
  }

  .contract-back-cover {
    break-before: page;
    page-break-before: always;
  }

  .contract-preview {
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .document:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
