:root {
  color-scheme: light;
  --bg: #edf2ee;
  --paper: #fff;
  --ink: #172a23;
  --muted: #53665d;
  --line: #dce5de;
  --green: #174e39;
  --green-dark: #0e3a29;
  --soft: #e8f3eb;
  --radius: 18px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #52866f; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

.topbar { background: #fafcf9; border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 69px; max-width: 1140px; padding: 0 28px; margin: auto; display: flex; align-items: center; gap: 36px; }
.brand, .customer-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; white-space: nowrap; text-decoration: none; }
.brand-mark { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px; background: var(--green); color: white; font-weight: 650; font-size: 15px; }
.views { display: flex; min-width: 0; align-items: center; align-self: stretch; gap: 23px; }
.views a { display: flex; align-items: center; border-bottom: 2px solid transparent; padding: 2px 1px 0; font-size: 14px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.views a[aria-current="page"] { color: var(--green-dark); border-color: var(--green); font-weight: 700; }
.environment { margin-left: auto; white-space: nowrap; font-size: 13px; color: var(--muted); }

.sign-layout { max-width: 1040px; margin: auto; padding: 34px 28px 56px; display: grid; grid-template-columns: minmax(230px, 1fr) minmax(0, 438px); align-items: center; gap: clamp(34px, 8vw, 112px); }
.intro { align-self: start; padding: 99px 0 0 20px; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--green); font-size: 13px; font-weight: 700; }
.eyebrow span, .device-label span { height: 7px; width: 7px; border-radius: 50%; background: #4a886c; }
.intro h1 { font-size: clamp(44px, 5.5vw, 74px); letter-spacing: -.072em; line-height: 1.12; margin: 19px 0 24px; }
.intro > p, .admin-heading p { color: var(--muted); font-size: 16px; line-height: 1.85; }
.intro > p { max-width: 280px; }
.flow { display: grid; gap: 14px; margin: 30px 0; color: #354e42; font-size: 14px; }
.flow div { display: flex; align-items: center; gap: 11px; }
.flow span { width: 11px; height: 11px; border: 1px solid #77a28c; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--bg); background: #9ab9a9; }
.quiet-link { display: inline-block; width: fit-content; padding: 11px 0; color: var(--green-dark); font-size: 14px; font-weight: 700; text-underline-offset: 5px; }
.device { min-width: 0; }
.device-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 0 0 11px 8px; }
.customer { overflow: clip; background: #f3f6f2; border: 1px solid #cbd8ce; border-radius: 26px; box-shadow: 0 16px 52px #253a2f15, 0 2px 5px #253a2f0a; }
.customer-head { min-height: 61px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); background: #fafcf8; }
.customer-brand { font-size: 15px; }
.customer-brand .brand-mark { width: 27px; height: 27px; border-radius: 7px; font-size: 13px; }
.status { flex: none; padding: 5px 10px; border: 1px solid #deccb0; border-radius: 100px; background: #f8eddb; color: #6f4b1d; font-size: 12px; font-weight: 700; }
.status.complete { color: #22533e; background: #e0f0e5; border-color: #bfdaca; }
.customer-content { padding: 19px 16px 13px; }
.contract-heading { padding: 5px 4px 19px; }
.contract-kicker { color: var(--green); font-size: 13px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.contract-heading h2 { font-size: clamp(26px, 5.2vw, 32px); letter-spacing: -.035em; line-height: 1.33; margin: 5px 0 9px; }
.contract-meta { display: flex; flex-wrap: wrap; gap: 7px 13px; color: var(--muted); font: 12px/1.5 system-ui, sans-serif; }
.contract-meta span + span { border-left: 1px solid #c2cec5; padding-left: 13px; }
.paper { padding: 16px 18px 19px; border-radius: 14px; border: 1px solid var(--line); background: white; }
.paper-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.paper-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.parties { padding: 10px 0 2px; display: grid; gap: 6px; }
.parties p { display: flex; gap: 10px; align-items: baseline; line-height: 1.6; font-size: 14px; }
.parties span { flex: none; color: var(--muted); }
.parties strong { font-weight: 650; overflow-wrap: anywhere; }
.paper section { margin-top: 12px; }
.paper h3 { font-size: 14px; line-height: 1.6; margin-bottom: 3px; }
.paper section p { color: #41534a; font-size: 14px; line-height: 1.7; }
.contract-seal { margin-top: 13px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }
.contract-seal canvas { display: block; width: 76px; height: 76px; }
.customer-actions { padding: 11px 16px max(11px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fafcf9; }
.customer-actions p { text-align: center; font-size: 12px; color: var(--muted); margin-top: 7px; }
.customer-actions p:empty { display: none; }

.button { min-height: 47px; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; width: 100%; font-size: 15px; font-weight: 700; line-height: 1.35; }
.primary { background: var(--green); color: white; }
.primary:hover { background: var(--green-dark); }
.primary:disabled { background: #dce6df; color: #52675c; }
.secondary { border-color: #bdcfc3; background: #fff; color: var(--green-dark); }
.secondary:hover { background: #f1f7f2; }
.success { display: grid; grid-template-columns: auto 1fr; gap: 9px; padding: 12px; margin-bottom: 12px; border: 1px solid #c4ddc9; border-radius: 12px; background: var(--soft); }
.success h3 { font-size: 16px; }
.success p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.success img { grid-column: 2; display: block; width: min(100%, 170px); height: auto; border: 1px solid #cee0d1; background: #fff; border-radius: 6px; }
.completion-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: white; background: var(--green); }

.admin-layout { max-width: 1018px; margin: auto; padding: 54px 28px 60px; }
.admin-heading h1 { margin: 12px 0 7px; letter-spacing: -.05em; font-size: clamp(33px, 5vw, 50px); line-height: 1.2; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 24px; align-items: start; }
.admin-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.admin-card h2 { font-size: 19px; line-height: 1.4; }
.admin-card form { margin-top: 20px; }
.admin-card label { display: block; margin-bottom: 7px; font-weight: 700; font-size: 14px; }
.admin-card input { width: 100%; padding: 12px; border: 1px solid #bdcfc3; border-radius: 9px; min-height: 47px; color: var(--ink); background: #fbfcfa; font-size: 16px; }
.field-help { font-size: 14px; color: var(--muted); margin: 8px 0 15px; line-height: 1.55; }
.form-message { font-size: 14px; color: var(--green); margin-top: 10px; }
.form-message:empty { display: none; }
.admin-next { border-top: 1px solid var(--line); margin-top: 19px; padding-top: 17px; }
.stamp-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stamp-title span, .storage-note { color: var(--muted); font-size: 13px; }
.stamp-preview { display: grid; place-items: center; min-height: 238px; margin: 16px 0 13px; border: 1px solid var(--line); border-radius: 11px; padding: 14px; background: conic-gradient(#edf1ed 25%, #fbfcfa 0 50%, #edf1ed 0 75%, #fbfcfa 0) 0 / 22px 22px; }
.stamp-preview canvas { display: block; width: min(100%, 218px); height: auto; }
.storage-note { margin-top: 15px; }

dialog { width: min(calc(100vw - 30px), 440px); max-height: calc(100dvh - 30px); overflow: auto; padding: 19px; border: 1px solid var(--line); border-radius: 19px; color: var(--ink); background: var(--paper); box-shadow: 0 16px 48px #102a2044; }
dialog::backdrop { background: #132a24a6; }
.dialog-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.dialog-top h2 { font-size: 22px; margin-bottom: 4px; }
.dialog-top p { color: var(--muted); font-size: 14px; }
.icon-button { flex: none; width: 44px; height: 44px; border: 0; border-radius: 9px; background: #eef3ef; font-size: 23px; color: var(--ink); }
.signature-area { position: relative; overflow: hidden; border: 1px solid #b6c9bd; border-radius: 9px; background: #f6f9f6; }
.signature-guide { position: absolute; inset: 0; display: grid; place-items: center; color: #566d60; pointer-events: none; }
.signature-area canvas { position: relative; width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; }
.text-button { display: block; min-height: 44px; margin-left: auto; border: 0; border-radius: 8px; padding: 0 8px; background: transparent; color: var(--green); font-weight: 700; font-size: 14px; }
.text-button:disabled { color: var(--muted); }
.consent { display: flex; align-items: center; gap: 9px; min-height: 44px; font-size: 14px; margin-bottom: 8px; cursor: pointer; }
.consent input { width: 19px; height: 19px; accent-color: var(--green); margin: 0; flex: none; }

.customer-only .topbar, .customer-only .intro, .customer-only .device-label { display: none; }
.customer-only .sign-layout { display: block; padding: 0; max-width: 500px; }
.customer-only .customer { display: flex; flex-direction: column; min-height: 100dvh; border-width: 0 1px; border-radius: 0; box-shadow: none; }
.customer-only .customer-content { flex: 1; }
.customer-only .customer-actions { position: sticky; bottom: 0; }

@media (max-width: 700px) {
  .topbar-inner { min-height: 57px; padding: 0 13px; gap: 17px; }
  .brand { font-size: 14px; gap: 6px; }
  .brand-mark { width: 28px; height: 28px; font-size: 13px; }
  .views { gap: 15px; margin-left: auto; }
  .environment, .intro, .device-label { display: none; }
  .sign-layout { display: block; padding: 0; max-width: 500px; }
  .customer { display: flex; flex-direction: column; min-height: calc(100dvh - 57px); border-width: 0; border-radius: 0; box-shadow: none; }
  .customer-content { flex: 1; }
  .customer-actions { position: sticky; bottom: 0; }
  .admin-layout { padding: 26px 15px 40px; }
  .admin-grid { grid-template-columns: 1fr; gap: 13px; }
  .admin-card { padding: 16px; }
}

@media (max-width: 390px) {
  .customer-head { min-height: 55px; padding: 0 14px; }
  .customer-content, .customer-actions { padding-left: 12px; padding-right: 12px; }
  .paper { padding: 13px 14px 15px; }
}

[hidden] { display: none !important; }
a.button { display: inline-flex; justify-content: center; align-items: center; text-decoration: none; }
select, textarea { font: inherit; }
textarea:focus-visible, select:focus-visible { outline: 3px solid #52866f; outline-offset: 3px; }
.admin-card select, .admin-card textarea { width: 100%; min-height: 45px; padding: 11px 12px; background: #fbfcfa; color: var(--ink); border: 1px solid #bdcfc3; border-radius: 9px; }
textarea { resize: vertical; line-height: 1.65; }
.subtext { color: var(--muted); line-height: 1.65; }
.form-message.error { color: #a32739; }
.form-message:not(:empty) { line-height: 1.55; }
.form-message:not(:empty) + .admin-heading { margin-top: 14px; }
.login-layout { max-width: 500px; margin: auto; padding: 12vh 24px 40px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 0 0 20px; }
.login-card { padding: clamp(24px, 5vw, 37px); box-shadow: 0 14px 36px #23392c0a; }
.login-card h1 { font-size: clamp(28px, 5vw, 34px); margin-bottom: 8px; letter-spacing: -.04em; }
.login-card input { margin-bottom: 17px; }
.login-card .button { margin-top: 3px; }
.workspace { display: grid; min-height: 100dvh; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar { padding: 25px 17px; background: #122d23; color: #e6f3eb; }
.sidebar .brand { padding: 0 9px; font-size: 17px; }
.sidebar .brand-mark { background: #d2ecdd; color: #163d2c; }
.sidebar nav { display: grid; gap: 7px; margin-top: 38px; }
.sidebar nav a { padding: 12px; border-radius: 8px; text-decoration: none; color: #c7dbce; font-size: 15px; }
.sidebar nav a:hover, .sidebar nav a[aria-current="page"] { background: #24513d; color: #fff; }
.workspace-body { min-width: 0; }
.workspace-bar { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 16px; background: #fbfdfb; border-bottom: 1px solid var(--line); padding: 8px clamp(19px, 4vw, 46px); color: var(--muted); font-size: 14px; font-weight: 700; }
.workspace-bar > div { display: flex; align-items: center; gap: 12px; }
.logout { padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--green); }
.workspace .admin-layout { max-width: 1350px; padding: 31px clamp(18px, 4vw, 46px) 50px; }
.admin-heading h1 { font-size: clamp(30px, 4vw, 43px); margin-top: 2px; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.split .button, .pager .button { width: auto; flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 24px 0 19px; }
.stat { display: grid; gap: 8px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.stat span { color: var(--muted); font-size: 14px; }
.stat strong { font: 650 clamp(24px, 4vw, 36px)/1.1 system-ui, sans-serif; color: var(--green-dark); }
.list-card { padding: 0; }
.list-head { padding: 15px 18px; flex-wrap: wrap; }
.admin-card .filters { display: flex; gap: 7px; align-items: center; margin: 0; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-height: 40px; padding: 7px 9px; }
.filters input { width: min(230px, 100%); }
.filters .button, .pager .button { min-height: 40px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 15px; border-top: 1px solid var(--line); min-width: 95px; font-size: 14px; vertical-align: middle; }
th { background: #f7faf7; color: var(--muted); font-weight: 600; white-space: nowrap; }
td:first-child, th:first-child { padding-left: 18px; min-width: 210px; }
td:last-child { min-width: 130px; }
td a { display: block; color: var(--green-dark); text-decoration: none; font-weight: 700; }
td a:hover { text-decoration: underline; }
td small { font-size: 12px; display: block; color: var(--muted); margin-top: 5px; white-space: nowrap; }
.status { display: inline-block; white-space: nowrap; font-size: 13px; }
.empty { text-align: center; padding: 42px 15px 48px; border-top: 1px solid var(--line); }
.empty h3 { font-size: 17px; margin-bottom: 8px; }
.empty .button { width: fit-content; margin-top: 17px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 13px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.pager button:disabled { opacity: .45; }
.stamp-preview img { display: block; width: min(100%, 218px); height: auto; }
.author-card { max-width: 760px; margin-top: 22px; }
#template-fields input, #template-fields textarea { margin-bottom: 14px; }
.notice { margin-top: 18px; padding: 12px 15px; background: #f8eddb; border-radius: 9px; color: #6f4b1d; }
.notice a { margin: 0 4px; text-underline-offset: 3px; font-weight: 700; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--green); text-underline-offset: 4px; font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, .55fr); gap: 16px; margin-top: 21px; align-items: start; }
.detail-aside { display: grid; gap: 15px; }
.detail-meta { display: grid; gap: 6px; margin: 13px 0 17px; }
.detail-meta div { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 9px; line-height: 1.5; font-size: 14px; }
.detail-meta dt { color: var(--muted); }
.detail-meta dd { margin: 0; overflow-wrap: anywhere; }
.detail-paper section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 15px; }
.detail-paper h3 { font-size: 16px; margin-bottom: 6px; }
.detail-paper p { line-height: 1.75; }
.detail-paper p, .paper section p { white-space: pre-wrap; overflow-wrap: anywhere; }
#fresh-link input { margin-bottom: 8px; }
#fresh-link { margin-bottom: 12px; }
.dialog-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.customer-only .sign-layout { max-width: 566px; }
.customer-only .customer { overflow: visible; }
.contract-heading h1 { font-size: clamp(27px, 6vw, 35px); letter-spacing: -.04em; line-height: 1.3; margin: 7px 0 9px; }
.paper section h2 { font-size: 16px; line-height: 1.6; margin-bottom: 4px; }
.paper section p { font-size: 16px; line-height: 1.75; }
.paper section { margin-top: 17px; }
.parties p { font-size: 15px; }
.contract-seal img { display: block; object-fit: contain; }
.success h2 { font-size: 17px; }
.customer-actions { z-index: 1; }
.message-page { max-width: 490px; margin: 12vh auto 0; padding: 23px; }
.message-page h1 { margin: 18px 0 9px; font-size: 26px; }
.message-page p { line-height: 1.7; color: var(--muted); }
.dialog-fallback[open] { position: fixed; z-index: 2; top: 50%; left: 50%; margin: 0; transform: translate(-50%, -50%); box-shadow: 0 0 0 110vmax #132a24a6; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 155px minmax(0, 1fr); }
  .sidebar { padding-inline: 11px; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 630px) {
  .workspace { display: block; }
  .sidebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; flex-wrap: wrap; }
  .sidebar .brand { padding: 0 2px; font-size: 14px; }
  .sidebar nav { display: flex; margin: 0; gap: 2px; }
  .sidebar nav a { padding: 9px 7px; font-size: 14px; }
  .workspace-bar { min-height: 47px; }
  .workspace .admin-layout { padding-top: 21px; }
  .list-head { gap: 9px; }
  .admin-card .filters { flex: 1 1 100%; }
  .filters input { width: min(185px, 100%); }
  .stat { padding: 13px 10px; }
  .stats { gap: 7px; }
}
