:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #172321;
  --muted: #69716f;
  --line: #dde4e1;
  --brand: #113c37;
  --brand-2: #1c806f;
  --accent: #c88a2d;
  --soft: #e9f4f0;
  --cool: #eef3f8;
  --danger: #a33a35;
  --shadow: rgba(27, 42, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f0f5f3 0%, var(--bg) 340px),
    var(--bg);
  color: var(--ink);
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 14px;
}

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

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.button-link {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  width: 100%;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 700;
  text-align: center;
}

.app {
  max-width: 1380px;
  margin: 0 auto;
  padding: 22px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 25px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(17, 60, 55, 0.22);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(25px, 2.7vw, 38px);
  letter-spacing: 0;
}

.actions {
  display: flex;
  gap: 10px;
}

.account-wrap {
  position: relative;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 18;
  width: 220px;
  display: grid;
  gap: 6px;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(10, 31, 29, 0.16);
}

.account-menu strong {
  color: var(--brand);
  padding: 4px 6px 8px;
}

.account-menu a,
.account-menu button {
  min-height: 38px;
  padding: 0 10px;
  display: grid;
  align-items: center;
  color: var(--ink);
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  text-decoration: none;
  font-weight: 700;
}

.primary,
.secondary {
  min-height: 44px;
  padding: 0 16px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.link-button {
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.primary:hover,
.secondary:hover,
.button-link:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 24px rgba(17, 60, 55, 0.18);
}

.primary:visited {
  color: #fff;
}

.secondary {
  background: white;
  color: var(--brand);
  border: 1px solid var(--line);
}

.plan-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px 18px;
  background: linear-gradient(90deg, var(--soft), #fff7e7);
  border: 1px solid #c7ded5;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(27, 42, 39, 0.06);
}

.plan-banner div {
  display: grid;
  gap: 3px;
}

.plan-banner span {
  color: var(--muted);
}

.plan-banner a,
.footer-links a,
.legal-page a {
  color: var(--brand);
  font-weight: 800;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 30px var(--shadow);
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  color: var(--brand);
  font-size: 28px;
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 30px var(--shadow);
}

.login-panel p {
  margin: 4px 0 0;
  color: var(--muted);
}

.login-actions {
  display: grid;
  gap: 8px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.step {
  min-height: 44px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(27, 42, 39, 0.05);
}

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

.hidden,
.old-block {
  display: none !important;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.editor {
  display: grid;
  gap: 14px;
}

fieldset,
details {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 38px var(--shadow);
}

fieldset {
  padding: 22px;
}

summary {
  cursor: pointer;
  padding: 18px;
  color: var(--brand);
  font-weight: 800;
}

.details-body {
  padding: 0 18px 18px;
}

legend {
  padding: 0;
  color: var(--brand);
  font-size: 19px;
  font-weight: 800;
}

.wizard-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-line {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.remember-row input {
  width: auto;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  outline: none;
  padding: 12px 13px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(28, 128, 111, 0.14);
}

textarea {
  resize: vertical;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.grid legend {
  grid-column: 1 / -1;
}

.items {
  display: grid;
  gap: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 92px 136px 38px;
  gap: 8px;
  align-items: end;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.item-row label {
  margin-top: 0;
}

.remove {
  height: 42px;
  background: #f7e8e5;
  color: var(--danger);
  font-size: 20px;
  line-height: 1;
}

.full {
  width: 100%;
  margin-top: 12px;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.preview {
  position: sticky;
  top: 18px;
}

.document {
  min-height: 820px;
  background: white;
  border: 1px solid #e8eeeb;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(27, 42, 39, 0.12);
  padding: 38px 40px 78px;
  position: relative;
  font-size: 12px;
}

.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 22px;
}

.doc-brand {
  color: var(--brand);
  font-size: 24px;
  font-weight: 800;
}

.doc-logo {
  display: block;
  width: auto;
  max-width: 180px;
  max-height: 84px;
  object-fit: contain;
  margin-bottom: 16px;
}

.doc-small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-line;
}

.doc-meta {
  min-width: 190px;
  text-align: right;
}

.doc-title {
  margin: 34px 0 10px;
  color: var(--brand);
  font-size: 26px;
}

.address-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 26px;
}

.doc-section-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-text {
  line-height: 1.6;
  white-space: pre-line;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 26px;
  font-size: 12px;
}

.quote-table th {
  background: var(--soft);
  color: var(--brand);
  text-align: left;
}

.quote-table th,
.quote-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
}

.quote-table .num {
  text-align: right;
}

.totals {
  width: min(100%, 360px);
  margin: 22px 0 0 auto;
  display: grid;
  gap: 8px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.grand {
  border-top: 2px solid var(--brand);
  padding-top: 10px;
  color: var(--brand);
  font-size: 17px;
  font-weight: 800;
}

.payment-terms {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.doc-footer {
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
  white-space: pre-line;
}

.print-notice {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 16px 18px;
  color: white;
  background: var(--brand);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(10, 31, 29, 0.28);
  font-weight: 800;
}

.print-notice.hidden {
  display: none;
}

.copy-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(12, 28, 25, 0.42);
}

.copy-card {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  gap: 14px;
  padding: 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(10, 31, 29, 0.28);
}

.copy-head,
.copy-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.copy-head strong {
  color: var(--brand);
  font-size: 22px;
}

.copy-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

#copyTextArea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.5;
}

.archive-card {
  width: min(760px, 100%);
}

.archive-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.archive-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.archive-row strong {
  color: var(--brand);
}

.archive-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.footer-links {
  display: flex;
  gap: 16px;
  margin-top: 22px;
  padding: 16px 0;
}

.legal-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.legal-page article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 30px var(--shadow);
  padding: 28px;
}

.legal-page h1 {
  margin-bottom: 18px;
}

.legal-page h2 {
  margin-top: 28px;
  color: var(--brand);
}

.legal-page p,
.legal-page li {
  line-height: 1.6;
}

.pricing-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-top: 22px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.pricing-card {
  display: grid;
  gap: 14px;
  align-content: start;
  grid-template-rows: auto auto auto 1fr auto;
  width: min(100%, 320px);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 30px var(--shadow);
  padding: 22px;
}

.pricing-card.featured {
  border: 2px solid var(--brand-2);
}

.pricing-card .primary.button-link {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
  box-shadow: none;
}

.pricing-card .primary.button-link:visited,
.pricing-card .primary.button-link:hover,
.pricing-card .primary.button-link:focus {
  color: var(--brand);
}

.pricing-page {
  max-width: 780px;
}

.pricing-page .pricing-grid {
  justify-content: center;
}

.pricing-page #proCheckout {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
  box-shadow: none;
}

.pricing-page #proCheckout:visited,
.pricing-page #proCheckout:hover,
.pricing-page #proCheckout:focus {
  color: var(--brand);
}

.pricing-page .stripe-note {
  display: none;
}

.price {
  color: var(--brand);
  font-size: 34px;
  font-weight: 900;
}

.pricing-card ul {
  padding-left: 18px;
  margin: 0;
}

.pricing-card li {
  margin: 8px 0;
}

.stripe-note {
  margin-top: 22px;
  padding: 16px;
  background: #fff7e8;
  border-left: 4px solid var(--accent);
}

.admin-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.admin-table {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.admin-row div {
  display: grid;
  gap: 4px;
}

.admin-row span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .workspace,
  .address-row {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 14px;
  }

  .header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .login-panel,
  .steps,
  .plan-banner,
  .dashboard,
  .pricing-grid,
  .admin-row,
  .grid,
  .item-row {
    grid-template-columns: 1fr;
  }

  .plan-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .document {
    min-height: 0;
    padding: 24px;
  }

  .doc-head {
    flex-direction: column;
  }

  .doc-meta {
    text-align: left;
  }
}

@media print {
  body {
    background: white;
  }

  .header,
  .editor,
  .plan-banner,
  .dashboard,
  .steps,
  .login-panel,
  .print-notice,
  .copy-panel,
  .footer-links {
    display: none;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .workspace {
    display: block;
  }

  .preview {
    position: static;
  }

  .document {
    box-shadow: none;
    border-radius: 0;
    min-height: auto;
    padding: 20mm 18mm 30mm;
  }

  .doc-footer {
    position: fixed;
    left: 18mm;
    right: 18mm;
    bottom: 10mm;
  }
}
