:root {
  --ink: #1f2937;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #ffffff;
  --canvas: #f3f5f8;
  --brand: #1957a6;
  --brand-dark: #134581;
  --danger: #b42318;
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); line-height: 1.5; }
a { color: var(--brand); }
.topbar { background: #143c6d; color: #fff; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 14px 22px; display: flex; justify-content: space-between; align-items: center; }
.brand { color: #fff; text-decoration: none; font-weight: 700; }
.link-button { border: 0; background: transparent; color: #d9e7ff; cursor: pointer; padding: 5px; }
.page-shell { max-width: 1180px; margin: 0 auto; padding: 34px 18px 80px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(21, 35, 55, .05); padding: 26px; margin-bottom: 22px; }
.narrow-card { max-width: 560px; margin: 70px auto; }
.hero-card { text-align: center; padding: 50px 30px; }
h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: .01em; }
h2 { margin: 0 0 16px; font-size: 19px; }
.form-intro { max-width: 900px; margin: 0 auto 20px; }
.form-intro h1 { font-size: 32px; }
.eyebrow { color: var(--brand); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 5px; font-weight: 700; }
.muted { color: var(--muted); }
.section-tip { margin: -10px 0 13px; color: var(--muted); font-size: 13px; }
.login-card { max-width: 480px; padding: 34px 36px 38px; }
.login-mark { display: inline-flex; padding: 5px 10px; border-radius: 999px; background: #e8f1ff; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.login-card h1 { margin-top: 16px; font-size: 28px; }
.login-subtitle { margin: 0 0 24px; font-size: 14px; }
.login-card form { display: grid; gap: 16px; }
.login-submit { width: 100%; min-height: 46px; margin-top: 4px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
input, select, textarea { width: 100%; border: 1px solid #cbd3df; border-radius: 7px; background: #fff; min-height: 40px; padding: 8px 10px; font: inherit; color: var(--ink); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(25, 87, 166, .14); border-color: var(--brand); }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 22px 0 0; margin: 0 0 26px; }
legend { padding: 0 10px 0 0; font-weight: 700; color: #173c6d; font-size: 17px; }
.form-grid { display: grid; gap: 15px; }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.required { color: var(--danger); padding-left: 3px; }
.choice-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 12px 0; }
.choice-group > label, .ack { flex-direction: row; align-items: center; gap: 6px; }
.choice-group input[type=checkbox], .choice-group input[type=radio], .ack input { width: 17px; min-height: 17px; }
.choice-label { font-weight: 700; margin-right: 5px; }
.inline-label { flex-direction: row !important; align-items: center; }
.inline-label input { min-width: 180px; }
.repeat-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.repeat-head, .repeat-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1.6fr 1.2fr; min-width: 680px; }
.four-col-table .repeat-head, .four-col-table .repeat-row { grid-template-columns: 1fr 1.5fr 1.5fr 1.1fr; }
.six-col-table .repeat-head, .six-col-table .repeat-row { grid-template-columns: 1fr 1fr 1.5fr 1fr 1.2fr 1fr; }
.five-col-table .repeat-head, .five-col-table .repeat-row { grid-template-columns: 1fr 1fr 1.5fr 1.2fr 1.1fr; }
.repeat-head span { background: #eef3fa; font-weight: 700; font-size: 13px; padding: 8px; border-right: 1px solid var(--line); }
.repeat-head span:last-child { border-right: 0; }
.repeat-row { border-top: 1px solid var(--line); }
.repeat-row input { border: 0; border-radius: 0; border-right: 1px solid var(--line); min-height: 42px; }
.repeat-row input:last-child { border-right: 0; }
.declaration { background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; font-size: 13px; }
.declaration p { margin: 0 0 8px; }
.declaration p:last-child { margin-bottom: 0; }
.ack { margin: 16px 0; font-weight: 700; }
.signature-wrap { display: flex; gap: 24px; align-items: flex-start; }
.signature-card { width: min(100%, 620px); padding: 16px; border: 2px solid #4d8fe8; border-radius: 12px; background: linear-gradient(180deg, #f5f9ff 0%, #ffffff 100%); box-shadow: 0 5px 16px rgba(25, 87, 166, .10); }
.signature-heading { display: flex; align-items: center; gap: 9px; color: #173c6d; font-size: 17px; }
.signature-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 23px; border-radius: 999px; background: #d92d20; color: #fff; font-size: 12px; font-weight: 700; }
.signature-help { margin: 6px 0 10px; color: var(--muted); font-size: 13px; }
#signature-pad { display: block; width: 100%; height: 190px; border: 2px dashed #6aa3ed; border-radius: 9px; background: #fff; touch-action: none; }
.field-caption { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 7px; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 16px; cursor: pointer; text-decoration: none; font: inherit; font-weight: 700; }
.button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button-secondary { background: #fff; color: var(--brand); }
.danger-button { background: #fff; color: var(--danger); border-color: #efb4b0; }
.button-row, .submit-row, .detail-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.submit-row { justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 20px; }
.form-message { margin-bottom: 16px; border-radius: 7px; padding: 10px 12px; background: #eef6ff; color: #174b83; }
.form-message.error, .error-text { background: #fff0ef; color: var(--danger); }
.link-box { padding: 12px 14px; background: #f7f8fa; border-radius: 7px; word-break: break-all; margin: 14px 0; }
.admin-header { margin: 10px 0 22px; }
.invite-form { display: grid; grid-template-columns: 1.4fr 180px auto; gap: 12px; align-items: end; }
.section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.section-heading h2 { margin: 0; }
.search-form { display: flex; gap: 10px; width: min(100%, 440px); }
.search-form input { flex: 1; width: 340px; min-width: 0; min-height: 44px; }
.search-form .button { min-width: 78px; min-height: 44px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 700; }
.list-meta { margin-top: 14px; color: var(--muted); font-size: 13px; }
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 34px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--brand); text-decoration: none; font-size: 13px; }
.page-link:hover { border-color: var(--brand); background: #f5f9ff; }
.page-link.current { border-color: var(--brand); background: var(--brand); color: #fff; font-weight: 700; }
.page-link.disabled { color: #98a2b3; background: #f7f8fa; cursor: not-allowed; }
.page-ellipsis { min-width: 20px; text-align: center; color: var(--muted); }
.status { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; background: #edf2f7; color: #475467; }
.status-completed { background: #e7f6ec; color: #16733d; }
.status-pdf_failed, .status-generation_failed { background: #fff0ef; color: var(--danger); }
.detail-actions { margin-bottom: 14px; }
.status-line { color: var(--muted); }
.error-text { margin-left: 8px; padding: 4px 8px; border-radius: 5px; }
.detail-grid { display: grid; grid-template-columns: 130px 1fr 130px 1fr; gap: 8px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 16px 0; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; word-break: break-all; }
.json-preview { max-height: 460px; overflow: auto; background: #101828; color: #d6e4ff; padding: 16px; border-radius: 8px; font-size: 12px; }
.detail-card h2 { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-card h2:first-of-type { margin-top: 12px; }
.detail-repeat-table { min-width: 680px; }
.detail-repeat-table td { white-space: normal; vertical-align: top; }
.success-panel { text-align: center; padding: 40px 10px; }
.inline-form { margin: 0; }

@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar-inner { padding: 12px 14px; }
  .page-shell { padding: 16px 8px 44px; }
  .card { padding: 14px 12px; border-radius: 9px; }
  h1, .form-intro h1 { font-size: 23px; line-height: 1.3; }
  .form-intro { padding: 0 4px; margin-bottom: 14px; }
  .form-intro .muted { font-size: 14px; }
  .section-tip { margin-top: -7px; font-size: 13px; line-height: 1.45; }
  .login-card { padding: 26px 20px 30px; }
  fieldset { padding-top: 17px; margin-bottom: 21px; }
  legend { font-size: 16px; }
  .three-col { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  label { gap: 5px; }
  input, select, textarea { min-height: 46px; font-size: 16px; border-radius: 8px; }
  textarea { min-height: 92px; }
  .choice-group { align-items: flex-start; gap: 8px 11px; margin: 11px 0; }
  .choice-label { flex-basis: 100%; width: 100%; margin-right: 0; }
  .choice-group > label, .ack { min-height: 34px; font-size: 15px; }
  .choice-group input[type=checkbox], .choice-group input[type=radio], .ack input { flex: 0 0 auto; width: 19px; min-height: 19px; }
  .inline-label { flex-direction: column !important; align-items: stretch; width: 100%; }
  .inline-label input { min-width: 0; }
  .repeat-table { overflow: visible; border: 0; }
  .repeat-head { display: none; }
  .repeat-row, .four-col-table .repeat-row, .six-col-table .repeat-row, .five-col-table .repeat-row {
    display: grid;
    grid-template-columns: 1fr;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
  }
  .repeat-row input, .repeat-row input:last-child { min-height: 45px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  .repeat-row input:last-child { border-bottom: 0; }
  .submit-row { padding-top: 15px; }
  .submit-row .button { width: 100%; min-height: 48px; font-size: 16px; }
  .invite-form { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .search-form { width: 100%; }
  .search-form input { width: auto; min-width: 0; flex: 1; }
  .search-form .button { flex: 0 0 76px; }
  .pagination { gap: 5px; }
  .page-link { min-width: 34px; padding-left: 8px; padding-right: 8px; }
  .detail-grid { grid-template-columns: 100px 1fr; }
  .detail-grid dt:nth-of-type(odd) { grid-column: 1; }
  .detail-grid dd { grid-column: 2; }
  .signature-wrap { display: block; }
  #signature-pad { width: 100%; height: 180px; }
  .signature-card { width: 100%; padding: 14px; }
  .signature-heading { font-size: 16px; }
  .signature-help { font-size: 13px; }
  .button-secondary { min-height: 44px; margin-top: 8px; }
}

@media (min-width: 761px) and (max-width: 980px) {
  .page-shell { padding-left: 14px; padding-right: 14px; }
  .three-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-3 { grid-column: auto; }
}
