/* Escritos (despacho del abogado): edición a la izquierda, revisión a la derecha y vista previa en papel. */
.escritos { display: grid; gap: 22px; }
.escritos > *, #v-editor > *, .editor-cuerpo > *, .barra-editor > * { min-width: 0; }
#v-editor { display: grid; gap: 16px; }
.cabeza-escritos { gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.cabeza-escritos h1 { font-size: clamp(2rem, 5vw, 3rem); }
.fila-borrador { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
.fila-borrador a { text-decoration: none; color: var(--tinta); }
.fila-borrador a:hover b { text-decoration: underline; }
.campo.corto { flex: 0 1 190px; }

/* Nuevo */
.tipos-escrito { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tipos-escrito legend { font-weight: 600; margin-bottom: 8px; }
.tipo-escrito { border: 1px solid var(--linea); border-radius: var(--r-control); padding: 12px; background: var(--superficie); }
.tipo-escrito:has(input:checked) { border-color: var(--oro); box-shadow: 0 0 0 1px var(--oro); }
.lista-hallazgos { display: grid; gap: 8px; max-height: 340px; overflow: auto; padding: 4px; }

/* Editor */
.barra-editor > .pila { flex: 1 1 420px; }
.barra-editor { display: flex; justify-content: space-between; gap: 14px; align-items: flex-end; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; background: var(--papel); padding: 10px 0; border-bottom: 1px solid var(--linea); }
.titulo-borrador { width: 100%; font-family: var(--f-titulo); font-size: clamp(1.3rem, 3vw, 1.8rem); border: 0; border-bottom: 1px dashed var(--linea-fuerte); border-radius: 0; padding: 4px 0; background: transparent; min-height: 0; }
.acciones-editor { align-items: center; }
.acciones-editor .campo.estado { flex: 0 0 160px; }
.acciones-editor select { min-height: 38px; padding-block: 6px; }
.editor-cuerpo { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .editor-cuerpo { grid-template-columns: minmax(0, 1fr); } }
.columna-revision { position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow: auto; }
@media (max-width: 960px) { .columna-revision { position: static; max-height: none; } }
.datos-escrito summary, #d-criterios summary, #d-documentos summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.grupo { border: 1px solid var(--linea); border-radius: var(--r-control); padding: 12px; display: grid; gap: 12px; margin: 0; }
.grupo legend { font-weight: 600; font-size: .9rem; padding: 0 6px; }
.tabla-valores input, .tabla-valores select { min-height: 38px; padding: 6px 8px; font-size: .9rem; }
.tabla-valores td { padding: 6px; }
.tabla-valores .num { text-align: right; }
.tabla-valores .v-tipo { min-width: 14rem; }
.tabla-valores .v-numero { min-width: 9.5rem; }
.tabla-valores .v-periodo { min-width: 6rem; }
.tabla-valores .v-concepto { min-width: 15rem; }
.tabla-valores .v-importe { min-width: 7.5rem; }
.leer-pdf { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#d-pdf-estado:empty { display: none; }
#d-pdf-estado.n-ok { color: var(--verde); }
#d-pdf-estado.n-aviso, #d-pdf-estado.n-error { color: var(--rojo); }

.seccion-escrito { gap: 10px; padding: 16px; }
.seccion-cabeza { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.num-seccion { color: var(--oro-tinta); font-weight: 600; }
.s-titulo { flex: 1 1 220px; font-weight: 600; min-height: 38px; padding: 6px 10px; }
.herramientas { gap: 0; }
.s-texto { font-family: var(--f-texto); font-size: .95rem; line-height: 1.6; min-height: 140px; }
.propuesta-ia { border-top: 1px dashed var(--linea-fuerte); padding-top: 12px; display: grid; gap: 10px; }
.ia-resultado { display: grid; gap: 10px; }

.revision-escrito h4 { font-size: .9rem; margin-top: 4px; }
.alertas, .citas { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alertas li, .citas li { font-size: .86rem; line-height: 1.45; padding: 8px 10px; border-radius: var(--r-control); border-left: 3px solid var(--linea-fuerte); background: var(--superficie-2); }
.alertas .n-error, .citas .n-error { border-left-color: var(--rojo); background: var(--rojo-bg); color: var(--rojo); }
.alertas .n-aviso, .citas .n-aviso { border-left-color: var(--ambar); background: var(--ambar-bg); color: var(--ambar); }
.alertas .n-ok, .citas .n-ok { border-left-color: var(--verde); background: var(--verde-bg); color: var(--verde); }
.citas a { font-weight: 600; }

/* Corpus */
.resultados-corpus { display: grid; gap: 10px; }
.resultado { border: 1px solid var(--linea); border-radius: var(--r-control); padding: 12px; display: grid; gap: 6px; background: var(--superficie); }
.extracto { font-size: .9rem; color: var(--suave); }
.extracto mark { background: color-mix(in srgb, var(--oro) 35%, transparent); color: var(--tinta); padding: 0 2px; border-radius: 3px; }
.tramo { display: grid; gap: 8px; }
.tramo-texto { white-space: pre-wrap; font-family: var(--f-texto); font-size: .88rem; max-height: 340px; overflow: auto; background: var(--superficie-2); border: 1px solid var(--linea); border-radius: var(--r-control); padding: 10px; margin: 0; }
.criterio { display: grid; gap: 8px; }
.criterio blockquote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--oro); background: var(--superficie-2); font-size: .92rem; }
.buscar-corpus { align-items: flex-end; }

/* Vista previa: papel A4 con formato de escrito */
.vista-previa { display: grid; gap: 10px; min-width: 0; }
.papel { overflow-x: auto; }
.papel { background: #fff; color: #111; border: 1px solid var(--linea); box-shadow: var(--sombra); padding: 2.2cm 2.2cm 2.2cm 2.6cm; max-width: 21cm; width: 100%; margin: 0 auto; font-family: Arial, "Helvetica Neue", sans-serif; font-size: 11pt; line-height: 1.5; text-align: justify; }
@media (max-width: 640px) { .papel { padding: 18px 16px; font-size: 10.5pt; } }
.papel h2 { font-family: Arial, "Helvetica Neue", sans-serif; font-size: 11pt; font-weight: 700; margin: 14pt 0 6pt; letter-spacing: 0; }
.papel p { margin: 0 0 8pt; }
.papel .sumilla { margin-left: 50%; font-weight: 700; text-align: left; }
.papel .destinatario { font-weight: 700; text-transform: uppercase; text-align: left; }
.papel .presentacion { margin-left: 45%; }
.papel .item { margin-left: 18pt; text-align: left; }
.papel .acapite { font-weight: 700; }
.papel .lugar-fecha { text-align: right; margin-top: 18pt; }
.papel .firmas { display: flex; flex-wrap: wrap; justify-content: space-around; gap: 24pt; margin-top: 54pt; }
.papel .firma { display: grid; justify-items: center; text-align: center; min-width: 6cm; }
.papel .firma .linea { border-top: 1px solid #111; width: 6cm; margin-bottom: 4pt; }
.papel table { border-collapse: collapse; width: 100%; margin: 6pt 0 10pt; font-size: 9.5pt; }
.papel th, .papel td { border: 1px solid #333; padding: 3pt 5pt; color: #111; background: #fff; white-space: normal; }
.papel .total td { font-weight: 700; }
.papel mark.falta { background: #fff3a0; color: #5b4400; padding: 0 2px; }
.papel .doc-titulo { text-align: center; font-weight: 700; font-size: 13pt; }
.papel .doc-sub { text-align: center; }
.papel .fuentes { font-size: 9pt; }

@media print {
  body.imprimiendo > *:not(main), body.imprimiendo .escritos > *:not(#v-editor), body.imprimiendo #v-editor > *:not(.vista-previa), body.imprimiendo .vista-previa > .seccion-titulo { display: none !important; }
  body.imprimiendo, body.imprimiendo main { background: #fff; padding: 0; margin: 0; }
  body.imprimiendo .papel { border: 0; box-shadow: none; padding: 0; max-width: none; }
  body.imprimiendo .papel mark.falta { background: #fff3a0; }
  @page { size: A4; margin: 2.5cm 2.5cm 2.5cm 3cm; }
}
