.escritos-page .tool-card,
.escritos-page .tool-info,
.escritos-page .signature-block {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  box-sizing: border-box;
  padding: 18px;
  margin-bottom: 20px;
}

.escritos-page .escritos-form {
  display: grid;
  gap: 18px;
}

.driver-lex-query textarea,
#driverLexQuery {
  min-height: 280px;
  resize: vertical;
}

.escritos-page fieldset {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 16px;
  margin: 0;
}

.escritos-page legend {
  padding: 0 8px;
  font-weight: 700;
}

.escritos-page label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.escritos-page input,
.escritos-page select,
.escritos-page textarea {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: #111;
  font: inherit;
}

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

.escritos-page select option {
  color: #111;
}

.escritos-page input::placeholder,
.escritos-page textarea::placeholder {
  color: #555;
}

.escritos-page input:focus-visible,
.escritos-page select:focus-visible,
.escritos-page textarea:focus-visible,
.escritos-page canvas:focus-visible {
  outline: 3px solid rgba(255,255,255,.42);
  outline-offset: 3px;
}

.escritos-page .tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.escritos-page .tool-button,
.escritos-page input[type="file"]::file-selector-button,
.escritos-page input[type="file"]::-webkit-file-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 132px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid rgba(15, 42, 15, 0.22);
  border-radius: 10px;
  color: #123012;
  background: linear-gradient(180deg, #f1f4f1 0%, #dfe5df 100%);
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 42, 15, 0.08), 0 8px 18px rgba(15, 42, 15, 0.08);
}

.escritos-page .tool-button:hover,
.escritos-page .tool-button:active,
.escritos-page .tool-button:focus-visible,
.escritos-page input[type="file"]::file-selector-button:hover,
.escritos-page input[type="file"]::file-selector-button:active,
.escritos-page input[type="file"]:focus-visible::file-selector-button,
.escritos-page input[type="file"]::-webkit-file-upload-button:hover,
.escritos-page input[type="file"]::-webkit-file-upload-button:active {
  border-color: rgba(15, 42, 15, 0.32);
  background: linear-gradient(180deg, #ffffff 0%, #f6f8f6 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(15, 42, 15, 0.12), 0 12px 22px rgba(15, 42, 15, 0.10);
}

.escritos-page .tool-button:focus-visible,
.escritos-page input[type="file"]:focus-visible::file-selector-button {
  outline: 3px solid rgba(15, 42, 15, 0.28);
  outline-offset: 3px;
}

.escritos-page .escritos-form input[type="date"] {
  max-width: 11rem;
  width: 100%;
}

.escritos-page .writing-radio-group,
.escritos-page .writing-attachments {
  display: grid;
  gap: 10px;
}

.escritos-page .writing-attachments {
  grid-column: 1 / -1;
  align-items: start;
}

.escritos-page .writing-radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.escritos-page .writing-radio-group input {
  width: auto;
  min-height: auto;
}

.escritos-page .attachment-list {
  display: grid;
  gap: 8px;
  padding-left: 0;
  list-style: none;
}

.escritos-page .attachment-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.escritos-page .attachment-list button {
  width: auto;
}

.escritos-page #addAttachmentFiles {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  align-self: start;
  width: auto;
  max-width: max-content;
  gap: .4rem;
  white-space: normal;
}

.escritos-page .writing-attachments input[type="file"] {
  color: inherit;
}

.escritos-page .audit-actions,
.escritos-page .audit-template-list {
  display: grid;
  gap: 12px;
}

.escritos-page .audit-actions {
  margin: 14px 0;
}

.escritos-page .audit-template-item {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  box-sizing: border-box;
  padding: 12px;
}

.escritos-page .audit-template-item h3 {
  margin: 0 0 10px;
}

.escritos-page .audit-template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.escritos-page .signature-block {
  display: grid;
  gap: 12px;
}

.escritos-page .signature-block canvas {
  width: 100%;
  max-width: 760px;
  height: 220px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

.escritos-page .form-notice {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.escritos-page fieldset[aria-labelledby="saved-data-title"] {
  grid-column: 1 / -1;
}

.escritos-page fieldset[aria-labelledby="saved-data-title"] p,
.escritos-page fieldset[aria-labelledby="saved-data-title"] .tool-actions,
.escritos-page fieldset[aria-labelledby="saved-data-title"] .form-notice {
  grid-column: 1 / -1;
}

.escritos-page fieldset[aria-labelledby="saved-data-title"] .tool-actions {
  align-items: center;
  gap: .75rem;
}

.escritos-page fieldset[aria-labelledby="saved-data-title"] .tool-button {
  min-width: 11rem;
  width: auto;
  white-space: normal;
}

.escritos-page .document-preview {
  background: #fff;
  color: #111;
  border-radius: 8px;
  padding: 24px;
  font-size: 15px;
  line-height: 1.45;
}

.escritos-page .document-preview h3,
.escritos-page .document-preview h4 {
  color: #111;
}

.escritos-page .document-preview h3,
.escritos-page .document-preview h4,
.escritos-page .document-preview p,
.escritos-page .document-preview ol,
.escritos-page .document-preview ul {
  margin-top: 0;
  margin-bottom: 10px;
}

.escritos-page .document-preview .document-data-block {
  margin: 12px 0;
}

.escritos-page .document-preview .document-data-block ul {
  display: grid;
  gap: 4px;
  list-style: none;
  padding-left: 0;
}

.escritos-page .document-preview .signature-image {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 16px 0 4px;
  border-bottom: 1px solid #222;
}

.escritos-page .document-preview .document-footer {
  margin-top: 12px;
  padding-top: 6px;
  border-top: 1px solid #ccc;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  color: #333;
}

.escritos-page .document-preview .document-footer p {
  margin: 0;
  white-space: normal;
  word-break: normal;
}

.escritos-page .document-preview .attachment-annex {
  page-break-before: always;
  margin-top: 28px;
}

.escritos-page .document-preview .attachment-annex img {
  max-width: 100%;
  height: auto;
}

@media (min-width: 780px) {
  .escritos-page fieldset {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .escritos-page fieldset label {
    grid-column: span 6;
  }

  .escritos-page fieldset label:has(textarea),
  .escritos-page fieldset label:has(select),
  .escritos-page fieldset .writing-radio-group,
  .escritos-page fieldset .writing-attachments,
  .escritos-page #dynamicFields label {
    grid-column: 1 / -1;
  }

  .escritos-page fieldset label:has([name="workerRoadType"]),
  .escritos-page fieldset label:has([name="companyRoadType"]) {
    grid-column: span 3;
  }

  .escritos-page fieldset label:has([name="workerRoadName"]),
  .escritos-page fieldset label:has([name="companyRoadName"]) {
    grid-column: span 9;
  }

  .escritos-page fieldset label:has([name="workerRoadNumber"]),
  .escritos-page fieldset label:has([name="workerFloor"]),
  .escritos-page fieldset label:has([name="workerDoor"]),
  .escritos-page fieldset label:has([name="companyRoadNumber"]),
  .escritos-page fieldset label:has([name="companyFloor"]),
  .escritos-page fieldset label:has([name="companyDoor"]) {
    grid-column: span 4;
  }

  .escritos-page fieldset label:has([name="workerPostalCode"]),
  .escritos-page fieldset label:has([name="companyPostalCode"]) {
    grid-column: span 3;
  }

  .escritos-page fieldset label:has([name="workerCity"]),
  .escritos-page fieldset label:has([name="companyCity"]) {
    grid-column: span 6;
  }

  .escritos-page fieldset label:has([name="workerProvince"]),
  .escritos-page fieldset label:has([name="companyProvince"]) {
    grid-column: span 3;
  }

  .escritos-page fieldset label:has([name="companyAddressExtra"]) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .escritos-page fieldset[aria-labelledby="saved-data-title"] .tool-button {
    width: 100%;
  }

  .escritos-page #addAttachmentFiles {
    justify-self: stretch;
    width: 100%;
    max-width: none;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm 14mm;
  }

  html,
  body {
    background: #fff !important;
  }

  body.escritos-page > :not(main),
  body.escritos-page main > :not(.preview-card),
  body.escritos-page .preview-card > :not(#documentPreview) {
    display: none !important;
  }

  body.escritos-page main,
  body.escritos-page .preview-card,
  #documentPreview {
    display: block !important;
    background: #fff !important;
    color: #111 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: 0 !important;
  }

  #documentPreview {
    border-radius: 0;
    font-size: 10.8pt;
    line-height: 1.3;
  }

  #documentPreview h3 {
    font-size: 13pt;
    line-height: 1.2;
  }

  #documentPreview h4 {
    font-size: 11.2pt;
    line-height: 1.2;
  }

  #documentPreview p,
  #documentPreview ol,
  #documentPreview ul {
    margin-bottom: 6pt;
  }

  #documentPreview .document-data-block {
    margin: 7pt 0;
  }

  #documentPreview .signature-image {
    width: 52mm;
    margin: 8pt 0 3pt;
  }

  #documentPreview .document-footer {
    margin-top: 6pt;
    padding-top: 3pt;
    font-size: 7.8pt;
    line-height: 1.1;
    text-align: center;
    color: #333;
  }

  #documentPreview .document-footer p {
    margin: 0;
    white-space: normal;
    word-break: normal;
  }

  #documentPreview .attachment-annex {
    page-break-before: auto;
    break-before: auto;
    margin-top: 8pt;
  }
}
