:root {
  --tinta: #1a1a1a;
  --papel: #fdfcf8;
  --borde: #d4cfc0;
  --acento: #1a2a5a;
  --suave: #f4f0e6;
  --error: #a02020;
  --ok: #2a6b3f;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--suave);
  color: var(--tinta);
  line-height: 1.5;
}
.app {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  min-height: 100vh;
}
.form-panel {
  background: var(--papel);
  border-right: 1px solid var(--borde);
  padding: 28px 24px 0;
  overflow-y: auto;
  max-height: 100vh;
}
.preview-panel {
  padding: 32px;
  overflow-y: auto;
  max-height: 100vh;
}
h1 {
  font-size: 1.3rem;
  margin: 0 0 4px;
  color: var(--acento);
}
.subtitle {
  font-size: 0.85rem;
  color: #777;
  margin-bottom: 8px;
}
.status {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 18px;
  min-height: 1em;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--error); }
fieldset {
  border: 1px solid var(--borde);
  border-radius: 4px;
  margin-bottom: 16px;
  padding: 12px 14px;
}
legend {
  font-weight: bold;
  font-size: 0.85rem;
  color: var(--acento);
  padding: 0 6px;
}
label {
  display: block;
  font-size: 0.8rem;
  margin: 8px 0 3px;
  color: #555;
}
input, textarea, select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--borde);
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
  color: var(--tinta);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--acento);
  outline-offset: 1px;
}
input:invalid { border-color: var(--error); }
textarea { resize: vertical; min-height: 60px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.char-count { font-size: 0.7rem; color: #999; text-align: right; }
.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  font-size: 0.85rem;
  margin-top: 4px;
}
.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--borde);
  border-radius: 4px;
  background: #fff;
  color: var(--tinta);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.checks label:hover { background: var(--suave); }
.checks label:has(input:checked) {
  background: var(--suave);
  border-color: var(--acento);
  color: var(--acento);
  font-weight: 600;
}
.checks input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--acento);
}
.actions {
  position: sticky;
  bottom: 0;
  background: var(--papel);
  padding: 12px 0;
  border-top: 1px solid var(--borde);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
button {
  flex: 1 1 140px;
  padding: 10px;
  border: none;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: bold;
}
.btn-primary { background: var(--acento); color: #fff; }
.btn-secondary { background: #fff; color: var(--acento); border: 1px solid var(--acento); }
.btn-ghost { background: transparent; color: #555; border: 1px solid var(--borde); }
button:hover { opacity: 0.85; }
button:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }

.acta {
  background: #fff;
  max-width: 780px;
  margin: 0 auto;
  padding: 60px 70px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  font-size: 11pt;
  line-height: 1.5;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.acta-header {
  position: relative;
  text-align: center;
  border-bottom: 2px solid var(--tinta);
  padding-bottom: 14px;
  margin-bottom: 24px;
}
.acta-header h2 { margin: 0; font-size: 1.15rem; letter-spacing: 1px; }
.acta-header .diegep { font-size: 0.85rem; color: #555; }
.acta-logo {
  position: absolute;
  top: 0;
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.acta-logo-left { left: 0; }
.acta-logo-right { right: 0; }
.acta-header-text { padding: 0 56px; }
@media print {
  .acta-logo { width: 38px; height: 38px; top: 0; }
}
.acta-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
  font-size: 10pt;
}
.acta-meta div { border-bottom: 1px solid #999; padding-bottom: 2px; }
.acta-meta span { color: #666; font-size: 9pt; }
.acta-intro { font-size: 10.5pt; margin: 0 0 18px; text-align: justify; }
.acta h3 {
  font-size: 0.95rem;
  color: var(--acento);
  margin: 18px 0 8px;
  border-bottom: 1px solid var(--borde);
  padding-bottom: 3px;
  break-after: avoid;
  page-break-after: avoid;
}
.acta .campo { margin: 4px 0; }
.acta .campo b { display: inline-block; min-width: 130px; }
.acta-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 10pt; }
.acta-table th, .acta-table td { border: 1px solid #999; padding: 6px 8px; text-align: left; vertical-align: top; }
.acta-table th { background: var(--suave); }
.acta p { margin: 6px 0; text-align: justify; white-space: pre-wrap; orphans: 3; widows: 3; }
.acta-intro, .acta p#o-motivo { text-align: justify; }
.acta p#o-hechos, .acta p#o-intervencion, .acta p#o-observaciones { text-align: left; }
.firmas { margin-top: 50px; display: grid; grid-template-columns: 1fr 1fr; gap: 40px 30px; break-inside: avoid; page-break-inside: avoid; }
.firma { border-top: 1px solid var(--tinta); padding-top: 6px; font-size: 9.5pt; text-align: center; break-inside: avoid; page-break-inside: avoid; }
.acta-table tr, .acuerdos li { break-inside: avoid; page-break-inside: avoid; }
.cierre { margin-top: 40px; text-align: center; font-style: italic; color: #555; font-size: 10pt; }
.vacio { color: #bbb; font-style: italic; }
ul.acuerdos { margin: 6px 0; padding-left: 22px; }
.foot-print { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .form-panel { max-height: none; border-right: 0; border-bottom: 1px solid var(--borde); }
  .preview-panel { max-height: none; padding: 16px; }
  .acta { padding: 32px 24px; }
}
@media (max-width: 600px) {
  .acta-logo { width: 32px; height: 32px; }
  .acta-header-text { padding: 0 40px; }
  .acta-header h2 { font-size: 1rem; }
}

@media print {
  body { background: #fff; }
  .form-panel, .actions, .status { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .preview-panel { padding: 0; max-height: none; overflow: visible; }
  .acta { box-shadow: none; padding: 0; margin: 0; max-width: 100%; }
  .foot-print { display: block; font-size: 8.5pt; color: #555; margin-top: 24px; text-align: center; border-top: 1px solid #999; padding-top: 4px; }
  @page { size: A4; margin: 18mm 20mm; }
}
