:root {
  --primary: #107E83;
  --primary-dark: #0B5F63;
  --gray: #787D7D;
  --light-bg: #EAF5F5;
  --border: #D6E7E8;
  --text: #263238;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, var(--light-bg), #ffffff);
  color: var(--text);
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* Header */
.main-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 16px 40px;
}

.header-content {
  max-width: 1050px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  height: 72px;
  object-fit: contain;
}

.header-title {
  color: var(--gray);
  font-size: 15px;
  font-weight: 600;
}

/* Layout */
.page-wrapper {
  max-width: 1050px;
  margin: 0 auto;
  padding: 70px 24px;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(16, 126, 131, 0.12);
  padding: 42px;
}

.hero-card {
  max-width: 620px;
  margin: 0 auto;
  text-align: center;
}

h1 {
  color: var(--primary-dark);
  font-size: 34px;
  margin-bottom: 14px;
}

.subtitle {
  color: var(--gray);
  font-size: 17px;
  line-height: 1.6;
  margin-bottom: 32px;
}

/* Forms */
.form-group {
  text-align: left;
  margin-bottom: 22px;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 126, 131, 0.14);
}

input[readonly] {
  background: #f3f7f7;
  color: var(--gray);
  cursor: not-allowed;
}

/* Buttons */
.btn-primary {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 15px 18px;
  background: var(--primary);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary-dark);
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.btn-secondary:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 8px 22px rgba(16, 126, 131, 0.18);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-link {
  display: inline-block;
  width: 100%;
  border-radius: 10px;
  padding: 15px 18px;
  background: var(--primary);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.btn-link:hover {
  background: var(--primary-dark);
  color: #ffffff;
}

/* Back button */
.page-action-row {
  margin: 0 auto 16px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.small-card-width {
  max-width: 620px;
}

.document-width {
  max-width: 900px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 15px;
  background: #ffffff;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 8px 22px rgba(16, 126, 131, 0.08);
}

.btn-back:hover {
  background: var(--light-bg);
  color: var(--primary-dark);
  text-decoration: none;
}

/* Index / verify pages */
.footer-note {
  margin-top: 22px;
  color: var(--gray);
  font-size: 13px;
}

.validation-message {
  color: #b3261e;
  font-size: 14px;
  margin-top: 8px;
}

.info-box {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin: 26px 0;
  background: #fbffff;
}

.info-box div {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.info-box div:last-child {
  border-bottom: none;
}

.info-box span {
  display: block;
  color: var(--gray);
  font-size: 14px;
  margin-bottom: 5px;
}

.info-box strong {
  color: var(--text);
  font-size: 16px;
}

/* Completion document page */
.document-card {
  max-width: 900px;
  min-height: 1100px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 42px 52px;
  box-shadow: 0 18px 45px rgba(16, 126, 131, 0.12);
  color: #000000;
}

.document-date {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  margin-bottom: 150px;
}

.document-title {
  font-family: Georgia, "Times New Roman", serif;
  color: #000000;
  font-size: 40px;
  text-align: center;
  margin-bottom: 130px;
}

.document-text {
  font-family: Georgia, "Times New Roman", serif;
  color: #000000;
  font-size: 20px;
  line-height: 1.45;
  text-align: left;
  margin-bottom: 22px;
}

.inline-input {
  display: inline-block;
  width: 250px;
  min-width: 190px;
  border: none;
  border-bottom: 2px dotted #000000;
  border-radius: 0;
  padding: 2px 6px;
  margin: 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  background: transparent;
}

.inline-input:focus {
  border-color: var(--primary);
  box-shadow: none;
}

.bottom-fields {
  margin-top: 220px;
  font-family: Georgia, "Times New Roman", serif;
}

.field-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 20px;
}

.field-line label,
.signature-block label {
  font-weight: 700;
  min-width: 280px;
}

.field-line input {
  flex: 1;
  border: none;
  border-bottom: 1px solid #000000;
  border-radius: 0;
  padding: 4px 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  background: transparent;
}

.fixed-value {
  flex: 1;
  border-bottom: 1px solid #000000;
  min-height: 32px;
  padding: 4px 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  color: #000000;
}

.document-submit {
  margin-top: 28px;
}

/* Messages */
.success-box {
  background: #e7f6ef;
  border: 1px solid #b9e3ce;
  color: #1f6b45;
  padding: 14px 16px;
  border-radius: 10px;
  margin: 20px 0;
  font-weight: 700;
}

.error-box {
  background: #fdeaea;
  border: 1px solid #f3b8b8;
  color: #9f1d1d;
  padding: 14px 16px;
  border-radius: 10px;
  margin: 20px 0 24px;
  font-weight: 700;
}

/* Signature */
.signature-block {
  margin-top: 16px;
}

.signature-add-btn {
  min-width: 180px;
}

.signature-error {
  display: none;
  margin-top: 8px;
  color: #b3261e;
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
}

.signature-invalid {
  border: 2px solid #b3261e !important;
}

.signature-preview-wrapper {
  display: none;
  border: none;
  padding: 0;
  background: transparent;
  margin-top: 10px;
  text-align: center;
}

#signaturePreview {
  display: block;
  width: 100%;
  max-width: 420px;
  height: 150px;
  object-fit: contain;
  margin: 0 auto 12px;
}

.signature-preview-wrapper .btn-secondary {
  display: inline-flex;
}

.signature-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #ffffff;
}

.signature-modal.active {
  display: block;
}

.signature-modal-open {
  overflow: hidden;
}

#signatureCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  cursor: crosshair;
  background: #ffffff;
}

.signature-modal-toolbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 10000;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
}

.signature-modal-buttons {
  display: flex;
  gap: 10px;
}

.signature-modal-buttons button {
  flex: 1;
}

.modal-save-btn {
  width: auto;
}

.modal-signature-error {
  display: none;
  margin: 0 0 10px;
  color: #b3261e;
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
}

/* Electronic signature notice */
.electronic-signature-note {
  max-width: 100%;
  margin: 18px auto 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
  color: #444444;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  white-space: nowrap;
}

/* ID attachment */
.hidden-file-input {
  display: none;
}

.attachment-block {
  margin-top: 26px;
  font-family: Georgia, "Times New Roman", serif;
}

.attachment-header {
  margin-bottom: 12px;
}

.attachment-header label {
  display: block;
  font-weight: 700;
  color: #000000;
  margin-bottom: 4px;
}

.optional-text {
  font-weight: 400;
  color: var(--gray);
  font-size: 16px;
}

.attachment-hint {
  margin: 0;
  color: var(--gray);
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
}

.attachment-options {
  display: grid;
  gap: 14px;
}

.attachment-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbffff;
  padding: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.attachment-action {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  cursor: pointer;
  margin: 0;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 400;
}

.attachment-action strong {
  display: block;
  color: var(--primary-dark);
  font-size: 15px;
  margin-bottom: 3px;
}

.attachment-action small {
  display: block;
  color: var(--gray);
  font-size: 13px;
  font-weight: 400;
}

.attachment-icon-circle {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: var(--light-bg);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, color 0.18s ease;
}

.upload-icon,
.camera-icon {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.attachment-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 22px rgba(16, 126, 131, 0.10);
}

.attachment-card:hover .attachment-icon-circle {
  background: var(--primary);
  color: #ffffff;
}

.selected-file-name {
  margin: 10px 0 0 56px;
  color: var(--gray);
  font-size: 13px;
  font-family: Arial, Helvetica, sans-serif;
  word-break: break-word;
}

/* Responsive */
@media (min-width: 769px) {
  .attachment-options {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .page-wrapper {
    padding: 14px;
  }

  .page-action-row {
    margin-bottom: 12px;
  }

  .btn-back {
    font-size: 14px;
    padding: 8px 13px;
  }

  .document-card {
    min-height: auto;
    padding: 24px 18px;
    border-radius: 8px;
  }

  .document-date {
    font-size: 15px;
    margin-bottom: 70px;
  }

  .document-title {
    font-size: 28px;
    margin-bottom: 70px;
  }

  .document-text {
    font-size: 17px;
    line-height: 1.6;
  }

  .inline-input {
    width: 100%;
    margin: 8px 0;
    font-size: 17px;
  }

  .bottom-fields {
    margin-top: 90px;
  }

  .field-line {
    display: block;
    font-size: 17px;
  }

  .field-line label,
  .signature-block label {
    display: block;
    min-width: 0;
    margin-bottom: 6px;
  }

  .field-line input,
  .fixed-value {
    width: 100%;
    font-size: 17px;
  }

  .signature-modal-toolbar {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .signature-modal-buttons {
    flex-direction: column;
  }

  #signaturePreview {
    max-width: 100%;
    height: 100px;
  }

  .electronic-signature-note {
    font-size: 10px;
    white-space: normal;
  }

  .selected-file-name {
    margin-left: 0;
  }
}

@media (max-width: 650px) {
  .main-header {
    padding: 14px 20px;
  }

  .header-content {
    flex-direction: column;
    gap: 10px;
  }

  .logo {
    height: 58px;
  }

  .card {
    padding: 28px 20px;
  }

  h1 {
    font-size: 27px;
  }
}

.review-pdf-card {
  max-width: 900px;
  margin: 0 auto;
}

.pdf-viewer-wrap {
  width: 100%;
  height: 720px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  margin: 24px 0;
}

.pdf-viewer {
  width: 100%;
  height: 100%;
  border: none;
}

@media (max-width: 768px) {
  .pdf-viewer-wrap {
    height: 620px;
  }
}

.pdf-js-viewer {
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid #ddd;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
}

.pdf-page-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto 16px auto;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.document-submit-form {
    margin-top: 20px;
}

.document-submit {
    width: 100%;
}

.visually-hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.camera-capture-card {
    display: block;
}

input[readonly] {
    background-color: #f3f3f3;
    cursor: not-allowed;
}