:root {
  --blue: #1d5f9f;
  --blue-dark: #174a7c;
  --red: #e55e45;
  --text: #2e2e2e;
  --muted: #657185;
  --line: #d7dbe3;
  --bg: #f4f6f9;
  --card: #ffffff;
  --danger: #b42318;
  --success: #157347;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.45;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--blue-dark);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: .2px;
}

.brand span {
  color: var(--blue-dark);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.topbar nav a {
  color: #303846;
  font-weight: 600;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.footer {
  padding: 20px 16px 32px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.panel,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.stack {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.form-wide {
  grid-column: 1 / -1;
}

.page-title {
  margin: 0 0 16px;
  color: #1d2b3a;
  font-size: 28px;
}

.subtle {
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  color: #fff;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

button:hover,
.button:hover {
  background: var(--blue-dark);
  text-decoration: none;
}

.button.secondary,
button.secondary {
  color: var(--blue);
  background: #fff;
}

.button.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #b9c1d0;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #222;
  font-weight: 700;
}

label .es,
.es {
  color: #2f3745;
}

label .zh,
.zh {
  color: var(--blue);
  font-weight: 600;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
}

.alert.success {
  color: var(--success);
  border-color: #b7dfc9;
  background: #edf8f1;
}

.alert.error {
  color: var(--danger);
  border-color: #f0b8b0;
  background: #fff2f0;
}

.alert.info {
  color: var(--blue-dark);
  border-color: #b8cee6;
  background: #eff6ff;
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f3f7;
  color: #1f2a38;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric strong {
  display: block;
  color: var(--blue-dark);
  font-size: 30px;
}

.questionnaire-paper {
  width: min(100%, 980px);
  margin: 0 auto 22px;
  padding: 44px 54px 58px;
  background: #fff;
  border: 1px solid #cfd5df;
  box-shadow: 0 12px 28px rgba(20, 35, 55, .08);
}

.q-head {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 80px;
  margin: -10px -54px 22px;
  padding: 0 54px 22px;
  border-bottom: 2px solid var(--red);
}

.q-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  border-bottom: 2px solid var(--blue);
  transform: skewY(-1.1deg);
}

.q-title {
  grid-column: 2;
  color: var(--blue);
  font-size: 23px;
  font-weight: 800;
  text-align: center;
}

.q-logo {
  justify-self: end;
  color: #214f89;
  font-size: 50px;
  font-weight: 900;
  line-height: 1;
}

.q-note {
  margin: 0 0 12px;
  color: #4f5765;
  font-size: 12px;
  text-align: right;
}

.q-ref {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  float: right;
  margin-bottom: 34px;
  padding: 8px 10px;
  background: #d8d8d8;
}

.q-ref input {
  width: 190px;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid #222;
  border-radius: 0;
  background: transparent;
}

.q-line-grid {
  clear: both;
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(210px, 1fr) minmax(230px, 1fr);
  gap: 14px;
  margin: 26px 0 18px;
}

.line-input {
  display: grid;
  gap: 4px;
  align-items: start;
  min-width: 0;
}

.line-input label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  min-width: 0;
}

.line-input input {
  width: 100%;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid #111;
  border-radius: 0;
}

.line-input input[type="date"] {
  min-height: 30px;
}

.q-block {
  margin: 18px 0;
}

.q-block strong {
  color: #30343b;
}

.q-small {
  color: #4b8bca;
  font-size: 13px;
}

.q-radio-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin: 9px 0;
}

.radio-pair {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
}

.radio-pair label {
  display: inline-flex;
  grid-auto-flow: column;
  gap: 4px;
  align-items: center;
  font-weight: 700;
}

.radio-pair input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.q-disease-list {
  width: min(720px, 100%);
  margin: 8px auto 0;
}

.q-disease {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 4px 0;
  font-weight: 800;
}

.q-textarea {
  margin-top: 8px;
}

.q-legal {
  margin-top: 22px;
  font-size: 10px;
  line-height: 1.25;
  color: #333;
}

.q-sign {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 18px;
  align-items: end;
  margin-top: 26px;
}

.q-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.consent-submit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.consent-submit-row .inline-checkbox {
  margin-right: 4px;
}

.q-data-table {
  width: 100%;
  margin-top: 20px;
  border-collapse: collapse;
  font-size: 15px;
}

.q-data-table th {
  background: #d7d7d7;
  color: #333;
  font-size: 20px;
  text-align: center;
}

.q-data-table th,
.q-data-table td {
  border: 1px solid #222;
  padding: 8px;
}

.q-data-table td:first-child {
  width: 30%;
}

.inline-checkbox {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  font-weight: 700;
}

.inline-checkbox input {
  width: 18px;
  height: 18px;
}

.print-toolbar {
  position: sticky;
  top: 78px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 auto 16px;
  width: min(100%, 980px);
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.completed-document .readonly-line {
  gap: 6px;
}

.readonly-field {
  display: block;
  min-height: 28px;
  padding: 4px 0 2px;
  border-bottom: 1px solid #111;
  color: #111;
  font-weight: 700;
  word-break: break-word;
}

.q-ref .readonly-field {
  min-width: 190px;
  padding-left: 8px;
}

.readonly-block {
  display: grid;
  gap: 6px;
}

.readonly-box {
  min-height: 68px;
  padding: 8px;
  border: 1px solid #9ca8ba;
  border-radius: 4px;
  background: #fff;
  white-space: normal;
}

.checkbox-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  border: 1px solid #222;
  color: #111;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
}

.readonly-yn {
  gap: 12px;
}

.upload-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.signature-field {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
}

.signature-pad {
  width: 100%;
  height: 180px;
  background: #fff;
  border: 1px solid #9ca8ba;
  border-radius: 6px;
  touch-action: none;
}

.signature-preview {
  display: block;
  width: min(360px, 100%);
  max-height: 120px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.insurance-page {
  position: relative;
  width: min(100%, 210mm);
  margin: 0 auto 16px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(20, 35, 55, .12);
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.insurance-bg {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.insurance-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.insurance-value {
  position: absolute;
  overflow: hidden;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 7.6pt;
  font-weight: 400;
  line-height: 1.08;
  white-space: normal;
  overflow-wrap: anywhere;
}

.insurance-value.small {
  font-size: 7.2pt;
  line-height: 1;
  white-space: nowrap;
}

.insurance-value.tiny {
  font-size: 6.4pt;
  line-height: 1;
  white-space: nowrap;
}

.insurance-value.area {
  padding: 1px 2px;
  font-size: 6.8pt;
  line-height: 1.1;
}

.insurance-value.center {
  text-align: center;
}

.insurance-value.measure {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 0;
  font-size: 6.2pt;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
}

.insurance-check {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 7.2pt;
  font-weight: 900;
  line-height: 1;
}

.insurance-image {
  position: absolute;
  object-fit: contain;
  object-position: center;
}

.insurance-image.signature {
  mix-blend-mode: multiply;
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .topbar,
  .footer,
  .print-toolbar,
  .no-print,
  .alert {
    display: none !important;
  }

  .container {
    width: 100%;
    margin: 0;
  }

  .questionnaire-paper {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 28px 38px;
    border: 0;
    box-shadow: none;
    page-break-after: always;
  }

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

  .q-head {
    margin-left: -38px;
    margin-right: -38px;
    padding-left: 38px;
    padding-right: 38px;
  }

  .insurance-page {
    width: 210mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
  }

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

  .insurance-bg {
    width: 210mm;
    height: 297mm;
  }
}

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

  .grid.two,
  .grid.three,
  .metrics,
  .q-line-grid,
  .q-sign {
    grid-template-columns: 1fr;
  }

  .questionnaire-paper {
    padding: 26px 18px 32px;
  }

  .q-head {
    grid-template-columns: 1fr;
    margin: -8px -18px 16px;
    padding: 8px 18px 20px;
  }

  .q-title {
    grid-column: 1;
  }

  .q-logo {
    justify-self: center;
    font-size: 42px;
  }

  .q-radio-row,
  .q-disease {
    grid-template-columns: 1fr;
  }
}
