:root {
  --ink: #172331;
  --muted: #687584;
  --navy: #13293d;
  --navy-2: #1c3f5c;
  --gold: #b88a44;
  --gold-light: #f5ecdd;
  --line: #dfe5ea;
  --surface: #ffffff;
  --background: #f3f5f7;
  --success: #16845b;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 12% -20%, #dce9f1 0, transparent 34rem), var(--background); }
button, input { font: inherit; }
button { cursor: pointer; }

.site-header {
  height: 74px; padding: 0 max(24px, calc((100% - 1120px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.9); border-bottom: 1px solid rgba(210,218,225,.85);
  backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20;
}
.brand { color: var(--navy); display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--navy); border-radius: 11px 4px 11px 4px; font-family: Georgia, serif; font-size: 23px; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .12em; font-size: 14px; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; letter-spacing: .18em; }
.secure-pill { color: #4e5d69; font-size: 13px; background: #f4f7f8; border: 1px solid var(--line); border-radius: 99px; padding: 7px 12px; }
.secure-pill i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: #20a36c; border-radius: 50%; box-shadow: 0 0 0 3px #d8f2e7; }

#app { width: min(1120px, calc(100% - 32px)); margin: 34px auto 64px; }
.loading { min-height: 50vh; display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--muted); }
.loading span, .button-spinner { width: 18px; height: 18px; border: 2px solid #c8d1d8; border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero { min-height: 168px; padding: 34px 42px; color: #fff; border-radius: 22px; background: linear-gradient(125deg, #10283d, #1c4868); box-shadow: 0 18px 48px rgba(19,41,61,.16); display: flex; align-items: center; justify-content: space-between; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; width: 310px; height: 310px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; right: -75px; top: -120px; box-shadow: 0 0 0 50px rgba(255,255,255,.025), 0 0 0 100px rgba(255,255,255,.02); }
.hero h1, .success-hero h1 { margin: 5px 0 7px; font-size: clamp(27px, 4vw, 38px); letter-spacing: .03em; }
.hero p, .success-hero p { color: rgba(255,255,255,.72); margin: 0; font-size: 15px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .2em; color: #dfc38f; }
.hero-stamp { position: relative; z-index: 1; width: 112px; height: 112px; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(255,255,255,.06); }
.hero-stamp b { font-family: Georgia, serif; font-size: 37px; font-weight: 400; line-height: 1; }
.hero-stamp span { font-size: 11px; margin-top: 7px; color: rgba(255,255,255,.72); }
.hero.compact { min-height: 148px; }
.invitation-badge { position: relative; z-index: 1; min-width: 245px; padding: 17px 20px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: 12px; }
.invitation-badge small, .invitation-badge b { display: block; }
.invitation-badge small { color: rgba(255,255,255,.6); margin-bottom: 4px; }

.steps { list-style: none; margin: 26px 12px; padding: 0; display: flex; justify-content: center; }
.steps li { width: min(190px, 24%); display: flex; align-items: center; gap: 9px; color: #8b96a0; font-size: 13px; position: relative; }
.steps li:not(:last-child)::after { content: ""; height: 1px; flex: 1; background: #d5dce2; margin: 0 12px; }
.steps span { flex: 0 0 auto; width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid #c8d0d7; border-radius: 50%; background: #fff; font-size: 12px; }
.steps .active { color: var(--navy); }
.steps .active span { color: #fff; background: var(--navy); border-color: var(--navy); box-shadow: 0 0 0 4px #dfe7ed; }
.steps .done { color: var(--success); }
.steps .done span { color: #fff; background: var(--success); border-color: var(--success); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .85fr); gap: 22px; align-items: start; }
.form-card, .summary-card, .share-card, .sign-card, .evidence-card, .signatures-card, .fatal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 28px rgba(24,45,62,.055); }
.form-card, .sign-card { padding: 30px; }
.card-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.card-heading .number { width: 44px; height: 44px; display: grid; place-items: center; color: var(--gold); background: var(--gold-light); border-radius: 12px; font: 17px Georgia, serif; }
.card-heading h2 { margin: 0 0 3px; color: var(--navy); font-size: 21px; }
.card-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.company-box { padding: 16px; display: flex; align-items: center; gap: 13px; background: #f6f8f9; border: 1px solid #e6eaed; border-radius: 12px; margin-bottom: 20px; }
.company-icon { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: var(--navy-2); border-radius: 10px; font-size: 12px; }
.company-box div { flex: 1; }
.company-box small, .company-box strong { display: block; }
.company-box small { color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.company-box strong { font-size: 15px; }
.verified { color: #1b7758; font-size: 11px; padding: 5px 8px; background: #e7f5ef; border-radius: 99px; }
label { color: #344250; font-size: 13px; font-weight: 650; display: block; margin: 17px 0 7px; }
input { width: 100%; height: 46px; padding: 0 14px; color: var(--ink); background: #fff; border: 1px solid #cfd7dd; border-radius: 9px; outline: none; transition: .2s; }
input::placeholder { color: #a3adb6; }
input:focus { border-color: #446d8c; box-shadow: 0 0 0 3px rgba(52,100,136,.1); }
.label-row { display: flex; justify-content: space-between; align-items: end; }
.text-button { padding: 0; margin-bottom: 7px; border: 0; color: #52718a; background: none; font-size: 12px; }
.signature-wrap { height: 185px; position: relative; border: 1px dashed #aeb9c2; border-radius: 10px; background: repeating-linear-gradient(0deg,#fff,#fff 36px,#f5f7f8 37px); overflow: hidden; }
.signature-wrap canvas { position: relative; z-index: 2; width: 100%; height: 100%; touch-action: none; }
.signature-wrap > span { position: absolute; inset: 0; display: grid; place-items: center; color: #b1bac2; font-size: 13px; pointer-events: none; }
.signature-wrap > i { position: absolute; height: 1px; background: #d2d8dd; left: 12%; right: 12%; bottom: 39px; }
.consent { display: flex; gap: 9px; align-items: flex-start; color: #5a6874; font-size: 12px; font-weight: 400; line-height: 1.55; cursor: pointer; }
.consent input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--navy); flex: 0 0 auto; }
.primary-button, .print-button { width: 100%; min-height: 48px; border: 0; border-radius: 9px; color: #fff; background: linear-gradient(110deg, var(--navy), #245574); box-shadow: 0 8px 20px rgba(19,41,61,.16); margin-top: 18px; font-weight: 650; letter-spacing: .02em; }
.primary-button span { float: right; margin-right: 5px; }
.primary-button:disabled { cursor: wait; opacity: .65; }
.button-spinner { display: inline-block; vertical-align: -4px; margin-right: 6px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.message { margin-top: 14px; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.message.error { color: #a0393e; background: #fff0f0; border: 1px solid #f0d0d2; }
.message.success { color: #177354; background: #eaf7f1; }

.summary-card { overflow: hidden; position: sticky; top: 96px; }
.summary-title { padding: 18px 20px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.summary-title span { color: var(--navy); font-weight: 700; }
.summary-title b { color: #8b96a0; font-size: 11px; padding: 4px 8px; background: #eef1f3; border-radius: 99px; }
.summary-card dl { margin: 0; padding: 10px 20px; }
.summary-card dl div { padding: 11px 0; display: flex; justify-content: space-between; border-bottom: 1px dashed #e1e5e8; gap: 15px; }
.summary-card dt { color: var(--muted); font-size: 12px; }
.summary-card dd { margin: 0; font-size: 12px; text-align: right; font-weight: 650; }
.summary-card .price { color: #9c6d27; font: 16px Georgia, serif; }
.security-note { margin: 7px 20px 20px; padding: 12px; color: #63717d; background: #f4f7f8; border-radius: 8px; font-size: 11px; line-height: 1.6; }
.security-note span { color: #1e815d; margin-right: 5px; }

.document-section { margin-top: 28px; }
.section-label { margin: 0 4px 10px; display: flex; align-items: baseline; gap: 12px; }
.section-label span { color: var(--navy); font-size: 18px; font-weight: 750; }
.section-label small { color: var(--muted); }
.paper { padding: 58px clamp(25px, 7vw, 82px); background: #fff; border: 1px solid #d9dee3; box-shadow: 0 12px 36px rgba(24,45,62,.07); min-height: 400px; }
.paper .contract { color: #202833; font-family: "Songti SC", SimSun, serif; line-height: 1.9; }
.paper .contract h1 { margin: 0 0 30px; color: #111a23; text-align: center; font: 700 clamp(23px, 3vw, 30px) "Songti SC", SimSun, serif; letter-spacing: .08em; }
.paper .contract h1::after { content: ""; display: block; width: 45px; height: 2px; margin: 14px auto 0; background: var(--gold); }
.paper .contract h2 { margin: 24px 0 7px; color: #172c3d; font-size: 16px; }
.paper .contract p { margin: 0; text-align: justify; font-size: 14px; text-indent: 2em; }
.paper .contract > p:first-of-type { padding: 13px 17px; background: #f6f7f8; border-left: 3px solid #9ca9b2; text-indent: 0; }
.loading-paper { display: grid; place-items: center; color: var(--muted); }

.success-hero { padding: 45px 25px 35px; text-align: center; color: #fff; border-radius: 22px; background: linear-gradient(125deg,#123426,#176149); box-shadow: 0 18px 48px rgba(22,97,73,.13); }
.success-icon { margin: 0 auto 12px; width: 48px; height: 48px; display: grid; place-items: center; color: #126043; background: #fff; border-radius: 50%; font-size: 24px; box-shadow: 0 0 0 8px rgba(255,255,255,.1); }
.success-hero .eyebrow { color: #a8e5cc; }
.success-hero.completed { padding-bottom: 40px; }
.print-button { width: auto; padding: 0 24px; background: #fff; color: #175640; box-shadow: none; margin-top: 20px; }
.share-card { padding: 31px; max-width: 820px; margin: 0 auto; }
.share-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.share-heading span { color: var(--navy); font-size: 18px; font-weight: 700; }
.share-heading small { color: var(--muted); }
.copy-row { display: flex; gap: 9px; }
.copy-row input { font: 12px ui-monospace, monospace; background: #f7f9fa; }
.copy-row button { min-width: 110px; color: #fff; border: 0; border-radius: 9px; background: var(--navy); }
.share-tips { display: flex; align-items: center; justify-content: space-between; padding: 24px; margin-top: 20px; background: #f6f8f9; border-radius: 10px; }
.share-tips div { display: flex; align-items: center; gap: 9px; color: #53616d; font-size: 12px; }
.share-tips b { width: 26px; height: 26px; display: grid; place-items: center; color: var(--navy); background: #fff; border-radius: 50%; }
.share-tips i { color: #a5afb8; }
.agreement-id { color: #89939c; font: 11px ui-monospace, monospace; text-align: center; margin: 20px 0 10px; }
.secondary-button { display: block; margin: 0 auto; padding: 9px 16px; color: #536675; border: 1px solid #d5dce1; border-radius: 8px; background: #fff; }

.signing-document { margin-top: 20px; }
.sign-card { max-width: 900px; margin: 24px auto 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1/-1; }
.lock-notice { color: #7a6541; background: #fff8e9; border-left: 3px solid #c99a4a; padding: 10px 12px; font-size: 12px; }

.evidence-card { padding: 16px 20px; display: grid; grid-template-columns: 1.3fr .7fr 2fr; gap: 18px; }
.evidence-card div { min-width: 0; padding-right: 18px; border-right: 1px solid var(--line); }
.evidence-card div:last-child { border: 0; }
.evidence-card small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.evidence-card code, .evidence-card strong { font-size: 11px; overflow-wrap: anywhere; }
.signatures-card { margin-top: 24px; padding: 30px; }
.signatures-card > h2 { color: var(--navy); margin: 0 0 18px; }
.signature-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.signature-columns article { padding: 23px; border: 1px solid var(--line); border-radius: 12px; }
.party-tag { color: #37617d; background: #e9f1f6; border-radius: 99px; padding: 5px 9px; font-size: 11px; }
.party-tag.seller { color: #886321; background: #f7eddc; }
.signature-columns h3 { min-height: 24px; margin: 13px 0; color: var(--navy); font-size: 17px; }
.signature-columns dl { margin: 0; }
.signature-columns dl div { display: flex; gap: 12px; margin: 7px 0; font-size: 12px; }
.signature-columns dt { min-width: 62px; color: var(--muted); }
.signature-columns dd { margin: 0; }
.signed-image { height: 150px; margin-top: 18px; position: relative; display: grid; place-items: center; border: 1px dashed #cbd3d9; background: #fafbfb; }
.signed-image img { max-width: 90%; max-height: 115px; }
.signed-image span { position: absolute; right: 8px; bottom: 6px; color: #9aa4ac; font-size: 9px; }
.legal-note { color: #89939c; text-align: center; font-size: 11px; }
.fatal-card { max-width: 560px; margin: 100px auto; padding: 50px; text-align: center; }
.fatal-card > span { width: 50px; height: 50px; display: grid; place-items: center; margin: 0 auto; color: #a9444a; background: #fff0f0; border-radius: 50%; font-size: 25px; }
.fatal-card h1 { color: var(--navy); }
.fatal-card p { color: #a0393e; }
.fatal-card small { color: var(--muted); }

.site-footer { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 30px; border-top: 1px solid #d9dfe4; display: flex; justify-content: space-between; color: #8a949c; font-size: 11px; }

@media (max-width: 760px) {
  .site-header { height: 64px; padding: 0 16px; }
  .secure-pill { display: none; }
  #app { width: min(100% - 22px, 650px); margin-top: 16px; }
  .hero { min-height: auto; padding: 25px 22px; border-radius: 15px; }
  .hero-stamp, .invitation-badge { display: none; }
  .hero h1 { font-size: 27px; }
  .steps { margin: 18px 0; justify-content: space-between; }
  .steps li { width: auto; gap: 5px; font-size: 10px; }
  .steps li:not(:last-child)::after { display: none; }
  .steps span { width: 24px; height: 24px; }
  .workspace, .form-grid, .signature-columns { grid-template-columns: 1fr; }
  .summary-card { position: static; order: -1; }
  .form-card, .sign-card { padding: 21px 17px; }
  .company-box { align-items: flex-start; }
  .verified { display: none; }
  .signature-wrap { height: 160px; }
  .paper { padding: 34px 20px; }
  .paper .contract p { font-size: 13px; }
  .share-card { padding: 22px 16px; }
  .share-heading { display: block; }
  .share-heading small { display: block; margin-top: 3px; }
  .copy-row { display: block; }
  .copy-row button { width: 100%; height: 44px; margin-top: 8px; }
  .share-tips { padding: 15px 10px; }
  .share-tips div { display: block; text-align: center; }
  .share-tips b { margin: 0 auto 5px; }
  .evidence-card { grid-template-columns: 1fr; }
  .evidence-card div { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 10px; }
  .site-footer { display: block; text-align: center; line-height: 2; }
  .site-footer span { margin: 0 6px; }
}

@media print {
  @page { size: A4; margin: 18mm; }
  body { background: #fff; }
  .site-header, .site-footer, .steps, .success-hero, .section-label, .no-print, .legal-note { display: none !important; }
  #app { width: 100%; margin: 0; }
  .document-section { margin: 0; }
  .paper { padding: 0; border: 0; box-shadow: none; }
  .paper .contract p { font-size: 10.5pt; }
  .paper .contract h2 { break-after: avoid; }
  .evidence-card, .signatures-card { box-shadow: none; break-inside: avoid; }
  .evidence-card { margin-bottom: 12mm; }
}
