:root {
  --green: #007f43;
  --green-light: #e8f7ee;
  --ink: #1f2937;
  --muted: #4b5563;
  --line: #9ca3af;
  --border-dark: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: #f3f4f6;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  line-height: 1.35;
}

/* Barra superior de herramientas (no se imprime) */
.no-print-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1e293b;
  color: white;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}

.no-print-bar p {
  margin: 0;
  font-size: 13px;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .95rem;
  border-radius: .4rem;
  border: 0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: #00a859;
  color: white;
}

.btn-primary:hover {
  background: #008f4c;
}

.btn-secondary {
  background: #475569;
  color: white;
}

.btn-secondary:hover {
  background: #334155;
}

/* Hoja física formal tamaño Carta */
.page-sheet {
  width: 216mm;
  min-height: 279mm;
  margin: 1.5rem auto 3rem;
  padding: 12mm 14mm;
  background: white;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .15);
}

/* Membrete Oficial */
.header-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  border: 1.5px solid var(--border-dark);
}

.header-table td {
  padding: 5px 8px;
  vertical-align: middle;
}

.header-logo {
  width: 65px;
  text-align: center;
  border-right: 1.5px solid var(--border-dark);
}

.header-logo img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.header-text {
  text-align: center;
}

.header-text h1 {
  margin: 0;
  font-size: 12px;
  font-weight: 900;
  color: var(--border-dark);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.header-text p {
  margin: 1px 0;
  font-size: 9px;
  color: var(--muted);
}

.header-meta {
  width: 120px;
  font-size: 8.5px;
  border-left: 1.5px solid var(--border-dark);
  background: #f8fafc;
  line-height: 1.3;
}

.form-title-banner {
  background: var(--border-dark);
  color: white;
  text-align: center;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Secciones y Bloques */
.section-block {
  margin-bottom: 7px;
  border: 1px solid var(--border-dark);
}

.section-heading {
  background: #e2e8f0;
  color: var(--border-dark);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  justify-content: space-between;
}

.section-body {
  padding: 6px 8px;
}

/* Cuadrícula de Campos */
.grid-row {
  display: grid;
  gap: 6px;
  margin-bottom: 5px;
}

.grid-row:last-child {
  margin-bottom: 0;
}

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

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

.col-4 {
  grid-template-columns: repeat(4, 1fr);
}

.col-1-2 {
  grid-template-columns: 1fr 2fr;
}

.col-2-1 {
  grid-template-columns: 2fr 1fr;
}

.col-3-1 {
  grid-template-columns: 3fr 1fr;
}

.col-1-3 {
  grid-template-columns: 1fr 3fr;
}

.field {
  display: flex;
  flex-direction: column;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

label {
  font-size: 8.5px;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.input-box {
  border-bottom: 1px solid var(--border-dark);
  min-height: 16px;
  font-size: 10px;
  color: #0f172a;
  padding: 1px 2px;
}

input[type="text"],
input[type="tel"],
input[type="email"],
select {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-dark);
  font-family: inherit;
  font-size: 10px;
  padding: 1px 2px;
  background: transparent;
  color: #0f172a;
  outline: none;
}

select {
  cursor: pointer;
  font-weight: 600;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 9px;
}

.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

.checkbox-item input {
  margin: 0;
}

/* Lista de Chequeo Documental */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 14px;
  font-size: 8.8px;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.checklist-item span {
  line-height: 1.25;
}

/* Cláusula Legal */
.legal-declaration {
  font-size: 7.8px;
  line-height: 1.35;
  color: #374151;
  text-align: justify;
  padding: 4px 6px;
  background: #f8fafc;
  border-top: 1px solid var(--border-dark);
}

/* Firmas */
.signatures-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.signatures-table td {
  width: 33.33%;
  padding: 4px 8px;
  text-align: center;
  vertical-align: bottom;
}

.signature-line {
  border-top: 1px solid var(--border-dark);
  margin-top: 36px;
  padding-top: 3px;
  font-size: 8.5px;
  font-weight: 700;
  color: #1e293b;
}

.signature-detail {
  font-size: 8px;
  color: #64748b;
}

/* Aviso de gratuidad */
.free-badge {
  font-size: 8px;
  font-weight: 800;
  text-align: center;
  color: var(--green);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Reglas Estrictas de Impresión */
@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .no-print-bar {
    display: none !important;
  }

  .page-sheet {
    width: 100% !important;
    margin: 0 !important;
    padding: 6mm 10mm !important;
    box-shadow: none !important;
    min-height: auto !important;
  }

  input,
  select {
    border-bottom: 1px solid black !important;
    -webkit-appearance: none;
    appearance: none;
  }

  .section-block,
  .header-table {
    border-color: black !important;
  }

  .section-heading,
  .form-title-banner {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Estilos movidos desde atributos style (compatibles con CSP) */
.u-1 { margin-top: 4px; }
.u-2 { border-bottom: 1px dotted #333; height: 12px; }
.u-3 { font-size: 7.8px; color: #475569; margin: 3px 0 6px 0; line-height: 1.3; }
.u-4 { width: 45px; }
.u-5 { background: #f1f5f9; padding: 3px 6px; margin-bottom: 4px; font-weight: 800; font-size: 8.5px; }
.u-6 { border-top: 1px dashed #cbd5e1; margin-top: 5px; padding-top: 4px; }

/* Adaptación a pantallas pequeñas (solo en pantalla; la impresión no cambia) */
@media screen and (max-width: 860px) {
  .no-print-bar { flex-wrap: wrap; padding: .6rem 1rem; }
  .no-print-bar p { flex: 1 1 100%; }
  .bar-actions { flex: 1 1 100%; flex-wrap: wrap; }
  .bar-actions .btn { flex: 1 1 10rem; justify-content: center; text-align: center; }
  .page-sheet { width: auto; min-height: 0; margin: .75rem; padding: 1rem .85rem; font-size: 12px; }
  .grid-row { grid-template-columns: 1fr !important; }
  .header-table, .header-table tbody, .header-table tr { display: block; width: 100%; }
  .header-table td { display: block; width: auto; border: 0; text-align: center; }
  .header-logo, .header-meta { width: auto; border: 0; }
  .header-meta { border-top: 1.5px solid var(--border-dark); }
  .page-sheet input, .page-sheet select, .page-sheet textarea { max-width: 100%; font-size: 14px; }
}

/* Transición suave al entrar/salir */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .22s ease both; }
::view-transition-new(root) { animation: vt-in .38s cubic-bezier(.22,.8,.3,1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; } }
