:root {
  color-scheme: light;
  font-family: "SimSun", "Songti SC", serif;
  color: #000;
  background: #e7e8eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #e7e8eb;
}

.paper-viewport {
  width: 100vw;
  max-width: 100%;
  overflow-x: auto;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #c9cbd0;
  font-family: system-ui, sans-serif;
  width: 100vw;
}

.toolbar__inner {
  width: min(210mm, calc(100vw - 32px));
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.toolbar button {
  height: 34px;
  padding: 0 16px;
  border: 1px solid #969ba5;
  border-radius: 4px;
  background: #fff;
  color: #202124;
  font: 14px system-ui, sans-serif;
  cursor: pointer;
}

.toolbar button:hover { background: #f4f5f7; }
.toolbar button:focus-visible { outline: 2px solid #1b62d1; outline-offset: 2px; }
.toolbar button:disabled { cursor: wait; opacity: 0.58; }
.toolbar .primary { background: #1f5fbf; border-color: #1f5fbf; color: #fff; }
.toolbar .primary:hover { background: #174f9f; }

.save-state {
  margin-right: auto;
  color: #62666d;
  font-size: 13px;
}

.paper {
  width: 210mm;
  min-height: 297mm;
  margin: 18px auto 36px;
  padding: 24mm 10mm 6mm;
  background: #fff;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.attachment {
  height: 7mm;
  font-size: 11pt;
  line-height: 7mm;
}

.form-header {
  text-align: center;
  font-family: "SimHei", "Heiti SC", sans-serif;
  line-height: 1.05;
}

.form-header h1 {
  margin: 0;
  font-size: 18pt;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.revision {
  margin-top: 1mm;
  font-size: 15pt;
}

.school-line {
  height: 8mm;
  margin-top: 2mm;
  display: flex;
  align-items: center;
  font-size: 11pt;
  font-weight: 700;
}

.school-line label { white-space: nowrap; }

input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: #000;
  font: inherit;
}

.school-line input {
  flex: 1;
  height: 100%;
  padding: 0;
  font-weight: 700;
}

input:focus { background: #fffbd9; }
input::placeholder { color: #888; opacity: 1; }

.form-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1.2px solid #000;
  font-size: 10.5pt;
}

.form-table .number-col { width: 5.1%; }
.form-table .label-col { width: 13.3%; }
.form-table .value-col { width: 16.7%; }
.form-table .right-label { width: 19.3%; }
.form-table .right-value { width: 39.7%; }

.form-table th,
.form-table td {
  height: 8.1mm;
  padding: 0 1.2mm;
  border: 0.75px solid #000;
  vertical-align: middle;
}

.form-table thead th {
  height: 8.2mm;
  padding: 0;
  text-align: center;
  font-weight: 700;
}

.form-table tbody td { text-align: center; }
.form-table tbody th { text-align: left; font-weight: 700; white-space: nowrap; }

.form-table .section th {
  height: 7.1mm;
  padding: 0;
  background: #c9c9ff;
  text-align: center;
  font-family: "SimHei", "Heiti SC", sans-serif;
  font-size: 12pt;
  line-height: 7.1mm;
}

.form-table input {
  display: block;
  width: calc(100% + 2.4mm);
  height: 8mm;
  margin: 0 -1.2mm;
  padding: 0 1.2mm;
  font-size: 10.5pt;
}

.form-table .unused { background: #fff; }

.signatures {
  height: 8mm;
  display: grid;
  grid-template-columns: 1.15fr 0.9fr 1.1fr;
  align-items: center;
  gap: 5mm;
  font-size: 10.5pt;
  font-weight: 700;
}

.signatures label {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.signatures input {
  flex: 1;
  height: 7mm;
  padding: 0 1mm;
  border-bottom: 0.6px solid transparent;
  font-weight: 400;
}

.signatures input:focus { border-bottom-color: #888; }

.footer-area {
  display: flex;
  align-items: flex-start;
  min-height: 15mm;
  font-size: 10.5pt;
  font-weight: 700;
}

.notes { line-height: 6mm; }
.notes div:last-child { padding-left: 14mm; }

.footer-area img {
  width: 16mm;
  height: 16mm;
  margin-left: 12mm;
  object-fit: contain;
}

@page { size: A4 portrait; margin: 0; }

@media screen and (max-width: 850px) {
  body { background: #f2f3f5; }

  .toolbar { padding: 8px; }
  .toolbar__inner {
    width: calc(100vw - 16px);
    gap: 6px;
  }
  .save-state { display: none; }
  .toolbar button {
    flex: 1;
    height: 40px;
    padding: 0 5px;
    font-size: 13px;
    white-space: nowrap;
  }

  .paper-viewport { overflow: visible; }
  .paper {
    width: auto;
    min-height: 0;
    margin: 10px;
    padding: 18px 14px 24px;
    box-shadow: none;
    overflow: visible;
  }
  .attachment { display: none; }
  .form-header h1 {
    font-size: 20px;
    line-height: 1.35;
    white-space: normal;
  }
  .revision { margin-top: 2px; font-size: 16px; }

  .school-line {
    display: block;
    height: auto;
    margin: 18px 0 14px;
    font: 600 15px system-ui, sans-serif;
  }
  .school-line label { display: block; margin-bottom: 6px; }
  .school-line input {
    display: block;
    width: 100%;
    height: 44px;
    padding: 0 10px;
    border: 1px solid #9ca1aa;
    border-radius: 4px;
    background: #fff;
    font: 16px system-ui, sans-serif;
  }

  .form-table,
  .form-table tbody { display: block; border: 0; }
  .form-table colgroup,
  .form-table thead { display: none; }
  .form-table tbody tr:not(.section) {
    display: grid;
    grid-template-columns: 34px minmax(112px, 0.85fr) minmax(0, 1.15fr);
    margin-bottom: 10px;
    border: 1px solid #a9adb5;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    font-family: system-ui, sans-serif;
  }
  .form-table th,
  .form-table td {
    display: flex;
    align-items: center;
    height: 46px;
    padding: 0 8px;
    border: 0;
    border-bottom: 1px solid #d2d4d9;
    white-space: normal;
  }
  .form-table tbody td { justify-content: center; }
  .form-table tbody th {
    font-size: 14px;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .form-table tbody tr:not(.section) > :nth-last-child(-n+3) { border-bottom: 0; }
  .form-table tbody tr:not(.section) > :nth-child(2),
  .form-table tbody tr:not(.section) > :nth-child(5) { border-left: 1px solid #d2d4d9; }
  .form-table tbody tr:not(.section) > :nth-child(3),
  .form-table tbody tr:not(.section) > :nth-child(6) { border-left: 1px solid #d2d4d9; }
  .form-table input {
    width: calc(100% + 16px);
    height: 45px;
    margin: 0 -8px;
    padding: 0 9px;
    background: #fff;
    font: 16px system-ui, sans-serif;
  }
  .form-table .unused { display: none; }
  .form-table .section {
    display: block;
    margin: 20px 0 10px;
  }
  .form-table .section:first-child { margin-top: 0; }
  .form-table .section th {
    display: block;
    width: 100%;
    height: auto;
    padding: 9px 10px;
    border: 0;
    border-radius: 4px;
    line-height: 1.35;
    font-size: 16px;
  }

  .signatures {
    height: auto;
    margin-top: 20px;
    grid-template-columns: 1fr;
    gap: 10px;
    font: 600 14px system-ui, sans-serif;
  }
  .signatures label { display: grid; grid-template-columns: auto 1fr; align-items: center; }
  .signatures input {
    height: 44px;
    padding: 0 8px;
    border: 1px solid #9ca1aa;
    border-radius: 4px;
    background: #fff;
    font: 16px system-ui, sans-serif;
  }
  .footer-area { margin-top: 16px; }
}

.export-mode .paper {
  margin: 0;
  box-shadow: none;
}
.export-mode input:focus { background: transparent; }
.export-mode input::placeholder { color: transparent; }

@media print {
  html, body { width: 210mm; height: 297mm; background: #fff; }
  body { min-width: 0; }
  .toolbar { display: none !important; }
  .paper-viewport { overflow: visible; }
  .paper {
    width: 210mm;
    height: 297mm;
    min-height: 0;
    margin: 0;
    box-shadow: none;
    break-after: avoid;
    page-break-after: avoid;
  }
  input:focus { background: transparent; }
  input::placeholder { color: transparent; }
}
